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

Webpack HMR does not refresh on HTML changes. #232

Closed
phyllisstein opened this issue Feb 19, 2016 · 7 comments
Closed

Webpack HMR does not refresh on HTML changes. #232

phyllisstein opened this issue Feb 19, 2016 · 7 comments

Comments

@phyllisstein
Copy link

I've been seeing an issue with Webpack, both 1.x and the 2.0 beta, wherein the hot module reloader doesn't refresh after to HTML templates. Webpack sees the change and logs the update, but the webpack/hot/dev-server module doesn't trigger a refresh.

I did a little amateur sleuthing, and it looks like using a subcompiler prevents the Webpack hash from being updated:

screen shot

When the hot reloader compares the new compilation hash against the old one (https://github.com/webpack/webpack/blob/master/hot/dev-server.js#L9), it just sees that the global compilation hasn't been updated and takes no action.

For the moment I'm making do with a slightly patched version of the HMR module that always returns false from check(). Sadly I don't have a sufficient understanding of Webpack's deep magic to dive in and fix this, but it seemed like something you might want to keep in your backlog.

Thanks for all your hard work on this plugin!

@jantimon
Copy link
Owner

open for pull requests

@nite-knite
Copy link

Is there any further information about this issue? It'd really be a convenience if pages update automatically when template changes. 😏

@jantimon
Copy link
Owner

jantimon commented Aug 2, 2016

I guess it's not possible - if so feel free to open a pull request

@TheLarkInn
Copy link
Collaborator

@jantimon Is this something that should be in the webpack-dev-server repo? Or is this a html-webpack-plugin related limitation? Just tracking.

@michaek
Copy link

michaek commented Aug 12, 2016

So far, I've approached this by publishing a custom event on webpack-hot-middleware, and consuming that event in client JavaScript, as in HenrikJoreteg/hjs-webpack#247 This approach isn't my idea, I originally saw it in this comment. As far as I can tell, it's not possible to live reload HTML without something of a hack, but it seems like a relatively benign hack that could possibly lead to a proper approach.

It seems like webpack-dev-server or webpack-hot-middleware are more appropriate to be concerned with this functionality than html-webpack-plugin, but I don't have a good sense of what API they would expose to trigger reloads in the browser.

@andreyvolokitin
Copy link

I suppose that this issue is somewhat historical and it never worked? If so, it is very interesting how is that possible considering years of existence of webpack ecosystem. Probably it was never in a spotlight due to the unpopularity of such use case. I saw repeated issues about this, also in webpack-dev-server repo (and created one myself: webpack/webpack-dev-server#1271), dated recently or 1-2 years ago, though these issues did not get much attention and were closed. Seeing current webpack-dev-server source it is clear that it simply was not meant to .reload() a page with hot: true, and probably always been that way, which is strange because it is valid use case...

Currently, I am trying to solve this, and I guess I can not use workaround with custom file watch, because my HTML is not static, it gets built by webpack, so I can't really "watch" HTML on a file system, and instead need a "native" ability to recognize and handle this...

@lock
Copy link

lock bot commented May 31, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants