HMR not working even with simple example
See original GitHub issueI am opening an issue because no one answered me on StackOverflow and I don’t know whether this is a bug or I am doing something wrong
- Operating System: Ubuntu 19.04
- Node Version: 12.1.0
- NPM Version: 6.9.0
- webpack Version: 4.30.0
- mini-css-extract-plugin Version: 0.6.0
Expected Behavior
I was expecting hmr to work with that configuration
Actual Behavior
Nothing happens, even on simple example
Code
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
plugins: [
new MiniCssExtractPlugin({
filename: "[name].css",
}),
],
entry: ["./style.css", "./app.js"],
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: "../",
hmr: process.env.NODE_ENV === "development",
reloadAll: true,
},
},
"css-loader",
],
},
],
},
};
How Do We Reproduce?
Here is link to repo with simple config and structure https://github.com/filipw01/mini-css-with-hmr
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Hot Module Replacement in Redux - Toptal
This is a minimal example of hot module replacement (or HMR) in a Redux application. The working demo code is hosted on GitHub....
Read more >Webpack HMR not reloading :- React - Stack Overflow
Actually HMR works when I make changes to app.js file for first time but after that it does not work even after reloading...
Read more >A Deep Dive into Hot Module Replacement with Webpack ...
The console says that Hot Module Replacement is enabled. By default, it is not. This project is configured to run with HMR.
Read more >Hot Module Replacement - webpack
HMR is not intended for use in production, meaning it should only be used in development. See the building for production guide for...
Read more >Webpack's Hot Module Replacement Feature Explained
Even a small change in the CSS code will refresh the browser. The Hot Module Replacement (HMR) feature was created to solve the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just started getting into this plugin and I also encountered the same problem. I found that
process.env.NODE_ENV
isundefined
, sohmr: process.env.NODE_ENV === 'development'
alwaysfalse
,I think it may be me, the configuration error in other places, in short is not a problem with this plugin.
Because hmr isn’t working and that was supposed to be the forcefull way to reload (which isn’t working anyway)