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

Does not rewrite html file contents on webpack watch/change :( #6

Open
AndrewRayCode opened this issue Apr 7, 2015 · 4 comments
Open

Comments

@AndrewRayCode
Copy link

If you change any source file while webpack is running, the plugin does not rewrite the paths in the built html file. You have to stop and re-run webpack.

@AndrewRayCode
Copy link
Author

Appears to be because you clear the modules after you process them? https://github.com/skozin/webpack-path-rewriter/blob/master/es6/index.js#L357

@skozin
Copy link
Owner

skozin commented Apr 9, 2015

No, that's because the loader doesn't get invoked unless you change the file it is rewriting. This is how Webpack currently works. So, when you change some other file, the hashes become different, but webpack-asset-rewriter has no chance to react to these changes.

Since this module consists of not only loader, but also a plugin, it might be possible to auto-update the target file, but I'm not sure (and have no time to experiment with this now). For now, the best strategy is to disable hashing during development. Eventually, this will be covered by examples in this repo, but until that you can find an example here. That setup supports hashing in production mode, source maps, livereload and hot stylesheets replacement.

Another thing that you may want to enable in development is the includeHash constructor option. It makes compilation hash dependent on the contents of all files being rewritten, so your app will auto-reload when any of these files (say index.html) changes. But this should be disabled during production build, as you definitely don't want the hash of your JS bundle to depend on the contents of some file that is not included in that bundle.

@AndrewRayCode
Copy link
Author

hmm - disabling hashing in dev sounds like a good idea. i'll try that and see if the whole thing works with that in place

@skozin
Copy link
Owner

skozin commented Apr 9, 2015

BTW, removing the line you linked in the previous comment might do the trick, but this will require some other changes in the logic of both loader and plugin, and a fair amount of testing. I'm not sure that it will not break something else)

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

No branches or pull requests

2 participants