nx: HMR not working - webpack custom config issue v15.4.2
Current Behavior
After updating the project from v14x to v15x the HMR stopped working. Now, whenever I make a change in a react component, a whole screen gets reloaded.
Expected Behavior
Yes, this is a regression. HMR used to work.
Code
"serve": {
"executor": "@nrwl/webpack:dev-server",
"options": {
"buildTarget": "app:build:development",
"port": 4203,
"hmr": true,
"liveReload": false
},
"configurations": {
"qas": {
"buildTarget": "app:build:qas",
"hmr": false
},
"production": {
"buildTarget": "app:build:production",
"hmr": false
}
}
},
Failure Logs
The same behavior is with or without the Live Reloading option enabled.
[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay enabled.
log.js:24 [HMR] Waiting for update signal from WDS...
And although the HMR reports that it is ready and waiting for updates, the whole screen reload still occurs.
Environment
Node : 16.14.0
OS : linux x64
yarn : 3.3.1
nx : 15.4.2
@nrwl/angular : Not Found
@nrwl/cypress : 15.4.2
@nrwl/detox : Not Found
@nrwl/devkit : 15.4.2
@nrwl/esbuild : Not Found
@nrwl/eslint-plugin-nx : 15.4.2
@nrwl/expo : Not Found
@nrwl/express : Not Found
@nrwl/jest : 15.4.2
@nrwl/js : 15.4.2
@nrwl/linter : 15.4.2
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : 15.4.2
@nrwl/react-native : Not Found
@nrwl/rollup : 15.4.2
@nrwl/schematics : 8.12.11
@nrwl/storybook : 15.4.2
@nrwl/web : 15.4.2
@nrwl/webpack : 15.4.2
@nrwl/workspace : 15.4.2
@nrwl/vite : 15.4.2
typescript : 4.8.4
---------------------------------------
Local workspace plugins:
---------------------------------------
Community plugins:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 21 (3 by maintainers)
I’ll take a look at that issue, thanks.
I found out what causes the issue. If I use the default Webpack config “@nrwl/react/plugins/webpack” it works, however, if I extend it, then it stops working.
This should be enough to reproduce the error:
project.jsonapps/not-working/webpack.config.tsReproducible repo: https://github.com/nemonemi/hmr-not-working-in-nx Custom Webpack config that breaks the HMR: https://github.com/nemonemi/hmr-not-working-in-nx/blob/main/apps/not-working/webpack.config.ts
@ndcunningham ?
I had same issue also, tried to play with the versions but didn’t help. I disabled
hmr: falseinproject.jsonand then added custom webpack with:found this guide for reference: https://dev.to/rexebin/enable-hot-module-replacement-hmr-in-nrwl-nx-react-project-1hh5