question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HMR not working even with simple example

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
ouweiyacommented, Jul 10, 2019

I just started getting into this plugin and I also encountered the same problem. I found that process.env.NODE_ENV is undefined, so hmr: process.env.NODE_ENV === 'development' always false,

I think it may be me, the configuration error in other places, in short is not a problem with this plugin.

2reactions
filipw01commented, May 7, 2019

Because hmr isn’t working and that was supposed to be the forcefull way to reload (which isn’t working anyway)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found