-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Sending more information in socket message for (hot) CSS reloading #542
Comments
I'm interested in this feature as well, at my work I use css reloading almost full-time, would be awesome if it works with hot reloading. |
You can't hot reload with ExtractTextPlugin. Webpack-dev-server works because its in memory not because of writing to file. Hot styles are emitted from your bundles js file. Delete your local ref to your css file, remove the extract text plugin. Your sass loader for dev mode should look something like this:
instead of :
|
@elisechant, while it is certainly true that you can use Sending the files that changed in the websocket could be interesting, also for other purposes. @jeroenransijn, would you be willing to do a PR for this? I don't know for sure where exactly you can get the changed files, but they should be somewhere in the |
I experimented a bit with this, it's possible to list the files that were changed. in var changedModules = stats.modules.filter(function(mod) {
return mod.built;
}).map(function(mod) {
return mod.name;
});
console.log('changed', changedModules); If you now change a CSS file or something, you'll see that only that file gets listed. I'm still not sure if we should include this in the WebSocket though. |
Hi I am looking at this one right now and have a few questions... Please forgive me if I am missing things as I am new to the webpack ecosystem and I have not looked at the whole source code of webpack-dev-server:
|
ok I have created an example here https://github.com/msuperina/webpack-dev-server/tree/master/examples/hmr-css |
@msuperina awesome work, very interesting. Note that this will not be accepted into webpack-dev-server since it shouldn't do anything with CSS. This should live as a separate package. |
@SpaceK33z thanks, I agree the CSS part should not be in the PR, it's only a consumer of the event. I will go ahead with a PR for client/index.js and Server.js as you seem to approve. |
I found that one webpack-contrib/extract-text-webpack-plugin#89 which seems to e be a better place to solve this. Will probably create a PR there. @SpaceK33z can you let me know if you still want a PR here to send metadata to the client in addition to the hash please ? |
Oh that PR you mentioned is awesome. For now I think we don't need that metadata. If someone has a good use case for it later on, we can always use your code. I'm going to close this since webpack-contrib/extract-text-webpack-plugin#89 essentially fixes the proposed use case. |
When using Webpack Dev Server for building CSS with ExtractTextPlugin there is no hot reloading. Which makes sense because there is no JS to actually trigger this.
There is a way to eaves drop on the client about Webpack updates by listening to the postMessage call when updates come in through SockJS. This script listens to all updates and refreshes the CSS (link elements):
This actually works fine but is triggered on any update, JS or CSS. The annoying part is that it dirties up your server logs and updates on no good reason if it's JS. It would be cool to make eaves dropping an actual feature where the event object contains more data about the update. The most important one would be file name including extension.
This is partially the webpack config I am using.
I am aware this is probably more a feature request than an issue.
The text was updated successfully, but these errors were encountered: