-
Notifications
You must be signed in to change notification settings - Fork 518
Add support for hot-reloading of styles #158
Comments
I've managed to add HMR for the styles by simply changing the loader for {
test: /\.css/,
loaders: ['style-loader', 'css-loader']
} Even though that embeds the whole I still need to add PostCSS with CSS Modules yet. |
Last time I checked, it explicitly wasn't possible with
Sure, definitely open to that. If there's an alternative that's mainstream, production-ready, and doesn't increase the concept count (so ideally not involving a new concept like PostCSS if possible), then that would be a great improvement. |
I tried a little bit today but no luck. These 2 kits have external .css with HMR: To me is more important to have HMR for styles in development, even though they are embedded in a If I ever make it work I'll post a new comment here. |
@SteveSandersonMS Well, the following loader generates an external css (although in the form of a blob) and also supports HMR. {
test: /\.css$/,
loaders: [
'style?sourceMap',
'css?modules&sourceMap&importLoaders=1&localIdentName=[local]___[hash:base64:5]',
]
}, I also want to use CSS Modules which the But I just can't make it work. Node.js is throwing an error when trying to import a .css file as a module. I tried all the different
And a huge inner stack trace below. Seems to be some kind of path issue on the server. The weird thing is that the import is in a component that's not being loaded in the If I disable server-side rendering (by removing the |
The homepage of the React/Redux template says: Hot module replacement. In development mode, you don't even need to reload the page after making most changes. Within seconds of saving changes to files, rebuilt CSS and React components will be injected directly into your running application, preserving its live state.
Then you should change the homepage to clarify that only .js files are hot reloaded. |
Great point. Updated the templates to avoid making the false claim. Thanks! |
@emzero I'm getting the same error trying to use CSS Modules, so I've disabled SSR for now. Please let me know if you find a solution. |
Currently if you change something in
ClientApp/css/site.css
in the ReactRedux template while the app is running the change is not reflected until you do a full refresh.The console ouputs the following:

According to the
extract-text-webpack-plugin
docs, it does not support hot module replacement.Would you considering switching to another style loader that does support HMR? And maybe including PostCSS?
I'm willing to do the work and create a PR if you agree. Bear in mind I'm pretty new to webpack, but I have time to hit my head on the wall until it works.
The text was updated successfully, but these errors were encountered: