HMR not working with multiple entries
See original GitHub issue- Operating System: Linux
- Node Version: 14.14.0
- NPM Version: 6.14.7
- webpack Version: 5.2.0
- webpack-dev-server Version: 3.11.0
- Browser: Google Chrome
- This is a bug
- This is a modification request
Code
https://github.com/slightlyfaulty/webpack-hmr-multi-entry-repro
// webpack.config.js
...
entry: {
first: ['./src/first.js', './src/first.css'],
second: ['./src/second.js', './src/second.css'],
},
...
Expected Behavior
After starting the dev server, hot module replacement should work for all JS and CSS files from all webpack entries.
Actual Behavior
Hot module replacement doesn’t work for all entries. Only files from the second entry are hot reloaded when changed. Files from the first entry do not get hot reloaded when changed.
For Bugs; How can we reproduce the behavior?
- Clone repro then
yarn && yarn start
- Open http://localhost:8080/
- Change
src/first.js
andsrc/first.css
- notice they are not hot reloaded - Change
src/second.js
andsrc/second.css
- notice they are hot reloaded
Issue Analytics
- State:
- Created 3 years ago
- Reactions:39
- Comments:56 (16 by maintainers)
Top Results From Across the Web
Webpack-dev-server HMR not working with multiple entry points
It seems like HMR has stopped working in my browser. Webpack is running and bundling it correctly! Any ideas? Thanks so far and...
Read more >Developers - HMR not working with multiple entries - - Bountysource
After starting the dev server, hot module replacement should work for all JS and CSS files from all webpack entries. Actual Behavior. Hot...
Read more >MiniCssExtractPlugin - webpack
Below is an example configuration of mini-css for HMR use with CSS modules. You should not use HotModuleReplacementPlugin plugin if you are using...
Read more >Hot Module Replacement - SurviveJS
Doing this pushes the problem to the application side. Enabling HMR#. The following steps need to be enabled for HMR to work: The...
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
@slightlyfaulty setting
optimization.runtimeChunk: "single"
fixed the problem for me.@khelkun I recently discovered that if you use the dependOn option for an entry, then it will use the runtime that’s embedded in the entry it depends on.
In this case you don’t need to use
runtimeChunk: 'single'
anymore, as long as thedependOn
entry is always loaded first.