-
Notifications
You must be signed in to change notification settings - Fork 513
Unable to HMR (Hot Module Replacement) css/scss with Webpack 2.2.0 and webpack-dev-server 2.2.1 #384
Comments
FYI - posted on stack overflow as well - http://stackoverflow.com/questions/41958586/unable-to-hmr-hot-module-replacement-css-scss-with-webpack-2-2-0-and-webpack-d |
As stated in the github main page of this plugin: You should not use this plugin while development, it is still useful for creating build for production. |
Fair point but I am confused as to why using version 1 on the library I was getting hot module replacement but version 2 of the library it is not available/working? |
Even in version 1, extract-text-webpack-plugin don't support HMR. Caveats: "No Hot Module Replacement" |
I've had my own very simple way of HMR with webpack 1 based on the Is this already part fo HMR? I guess webpack's basic asset watching should work anyway—or am I missing something important? |
While the documentation states Caveats: "No Hot Module Replacement", the documentation and behaviour do not match. Checkout the following repo and commit to see HMR working perfectly with version 1, when you have the client running try and change a scss style to see it recompile the css and refreshing the browser to automatically see the styling change. Repo: https://github.com/Rob-Leggett/react_redux_webpack This all stop working in the next commit, when I upgraded to version 2. |
The internal API changed in webpack 2. We would welcome a PR adding HMR support, but it's not simply supported at the moment. It's better to have development specific configuration (multiple ways to do that) and it's faster too that way. There was some initial effort at #89 if you are interested in working on this. |
The 'hot-update.js' file: webpackHotUpdate(0,{
/***/ "./components/App.css":
/***/ (function(module, exports) {
eval("// removed by extract-text-webpack-plugin\nmodule.exports = {\"app\":\"App__app-26iGG\",\"h2\":\"App__h2-o5GaB\",\"webpack\":\"App__webpack-1iiUZ\"};//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW...joiIn0=");
/***/ })
}) The bowser will reflush , but the method is return null. So the styles is not change. |
Can you try this |
@sajidali,I've been trying to use your suggetion, but it doesn't work |
@Rob-Leggett ,hi, i also encountered the same problem with you! if you find the solution,I hope you can also the solution send me , my email address is wshicheng@outlook.com ! thanks a lot |
@sajidali This package works wonderfully! Example of working HMR with styles and javascript.
|
@sajidali Great job! Here my fully working webpack.config.js with Sass compiling and reloading instantly ;)
|
@sajidali thanks! it does work this loader don't refresh browser, don't be confused |
In my case, the plugin "extract-text-webpack-plugin" began to work with hot reload after I deleted the bracket characters in the name of the project folder and replaced the spaces with "_". |
@iuliaL Thank you solved the problem。love you |
Thanks,this is good! |
@Oscar-ren Is it possible to make this solution refresh the browser? I tried browsersync and that works. But I'm wondering if this works wit webpack-dev-server as well. This would be a cleaner solution. |
@katiasmet I run the |
@Oscar-ren Ok so you have the same problem as me, but couldn't find a solution yet? Does anybody know how you can hot load sass changes? With or without the extract text webpack plugin? |
I've created https://github.com/sheerun/extracted-loader for this use case with no configuration. config.module.rules.push({
test: /\.css$/,
use: ['extracted-loader'].concat(ExtractTextPlugin.extract({
/* Your configuration here */
}))
})
config.plugins.push(new ExtractTextPlugin('index.css')) |
Versions
"extract-text-webpack-plugin": "^2.0.0-rc.2",
"webpack": "^2.2.0",
"webpack-dev-server": "^2.2.1"
Issue
"extract-text-webpack-plugin": "^1.0.1",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2"
No longer able to HMR css/scss since upgrading to version 2, changing the styles triggers a change (see output sample below) but I have to manually refresh the page to see the changes the page does not auto refresh, also if I make a change to a js file after changing a scss file the changes are then reflected as the js change trigger a HMR which also includes the style changes, but only changing the styles with no js changes requires a manual page refresh.
Command running:
npm run dev
Configuration before upgrade:
Configuration after upgrade:
Output sample initial page load.
Output sample after scss change.
You can see the size of the main.css changed, but the page never refreshed until I pressed f5
The text was updated successfully, but these errors were encountered: