mariusbalcytis / webpack-bundle

Bundle to Integrate Webpack into Symfony
MIT License
122 stars 36 forks source link

hot reloading for twig files not working? #17

Closed lakhman closed 8 years ago

lakhman commented 8 years ago

I just tried a fresh install of this, when I update the base.html.twig or any other twig files, it doesn't update, is this possible?

So when I save a twig file, it reloads the current page (not a hot reload, just like live reload).

Does it require any specific configuration?

mariusbalcytis commented 8 years ago

No, sadly it does not work this way. maba:webpack:dev-server command scans twig files in configured directories and searches for webpack_asset function usages. It builds list of entry points and passes that to webpack configuration file. Then it starts webpack-dev-server. It sleeps for a second and repeats the process. If entry points are changed, it restarts the process. Hot reloading is enabled only in the webpack-dev-server itself, as it generates javascript file that does this hot-reloading. It is unaware of changes inside twig files.

So, we have some different situations:

lakhman commented 8 years ago

Great, thanks for confirming, I had a feeling it wouldn't work like this, but was in 2 minds as the docs state:

Watches twig templates for changes, updates entry points and restarts webpack-dev-server if webpack configuration changes.

jrysig commented 7 years ago

Based on How to watch twig files with Webpack and Symfony? I did try proposed solution using watchFile-webpack-plugin. When I change twig file, webpack compilation is triggered and browser is notified. Unfortunately browser is not reloaded because of [WDS] Nothing changed..

Navigated to http://127.0.0.1:8000/
client:37 [WDS] App updated. Recompiling...
client:37 [WDS] Nothing changed.
client:37 [WDS] App updated. Recompiling...
client:37 [WDS] Nothing changed.
client:37 [WDS] App updated. Recompiling...

Is there any chance to force browser reload in this case?

mariusbalcytis commented 7 years ago

What exactly do you change? Do you add new entry point, change existing one, remove one?

Could you make separate issue for this if needed?

I don't think that watchFile-webpack-plugin would be a good option with this bundle in general, as it would watch all twig files for all assets, as I imagine. Generally there could be many entry points and many twig templates, so changing one of them should not require regeneration of all entry points. Furthermore, bundle itself must process twig files to update webpack configuration as needed.