fullpipe / twig-webpack-extension

Inject your webpack entry points into twig templates with easy.
MIT License
51 stars 14 forks source link

Try to inject webpack bundle result in a 404 #1

Closed korsmakolnikov closed 7 years ago

korsmakolnikov commented 7 years ago

When I've try to use your bundle to load javascript bundle, token is parsed with controllers context route (like route/edit/bundle.js for example) instead of producing relative path from web/, resulting in a 404. Parsing only the hashed file name and put it in href attribute is more familiar use (see asset function) and works perfectly.

fullpipe commented 7 years ago

Is it possible to resolve path relation with publicPath parameter?

The problem with your approach is that if we use ExtractTextPlugin, then for each entry point we need to control extracted part in twig templates. And its a headache if we have many entry points or separate frontend team.

korsmakolnikov commented 7 years ago

edit I feel stupid. I found the problem. Have to prepend a slash in publicPath parameter. By the way, for "manifest" parameter you cannot prepend a slash. So... My parameters is like: webpack.manifest: assets/webpack-manifest.json webpack.publicPath: /assets/

I fix it and make you a pull request.

old reply You already use publicPath and it has no benefit. Symfony always try to search the bundle in the wrong route. We could try to extract absolute url instead of relative and came back to master... Then we could cycle all the entry with a single command like you want. What you think?

korsmakolnikov commented 7 years ago

See other pull https://github.com/fullpipe/twig-webpack-extension/pull/2