Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using puli.json for webpack asset mapping #188

Open
robinvdvleuten opened this issue Mar 29, 2016 · 3 comments
Open

Using puli.json for webpack asset mapping #188

robinvdvleuten opened this issue Mar 29, 2016 · 3 comments

Comments

@robinvdvleuten
Copy link

We're using Puli to have some sort of asset mapping of assets produced by Webpack, it looks like this;

{
  "/app/style/js/modernizr.js" : "js/modernizr-4ea3c5271307e0573488.min.js",
  "/app/style/js/scripts.js" : "js/scripts-4ea3c5271307e0573488.min.js"
}

Now I would like to generate an url for the assets in our twig templates like this;

<script src="{{ resource_url('/app/style/js/scripts.min.js') }}">

But the generated url is http://localhost:8888/js/scripts.js where I expected http://localhost:8888/js/scripts-4ea3c5271307e0573488.min.js.

Is such setup possible with Puli?

@tgalopin
Copy link
Contributor

I'm not sure it's possible right now but in the near future, you will be able to use puli.js (it will be put in the Puli organization as soon as it's ready) :) .

@webmozart is it currently possible with the PHP implementation?

@ju1ius
Copy link

ju1ius commented May 14, 2016

This issue is not related solely to webpack. The output of the url generator does not take path mappings into account.

$ mkdir -p res/public
$ touch res/public/app_12345.js
$ puli map /res res
$ puli map /res/public/app.js res/public/app_12345.js
$ mkdir web
$ puli server --add localhost web
$ puli publish /res/public localhost
$ puli publish --install
$ tree
├── res
│   └── public
│       └── app_12345.js
└── web
    └── app_12345.js --> ../res/public/app_12345.js
$repository->get('/res/public/app.js')->getFilesystemPath();
// returns "/path/to/res/public/app_12345.js"
$urlGenerator->generateUrl('/res/public/app.js');
// returns "/app.js" instead of "/app_12345.js"

@webmozart
Copy link
Member

This is currently not possible, as you found out. We should add a possibility to maintain the original file name when installing assets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants