Disable Hot Module Replacement for certain chunks.
npm i -D hmr-filter-webpack-plugin
# or
yarn add -D hmr-filter-webpack-plugin
// webpack.config.js
const {
HotModuleReplacementFilterPlugin
} = require('hmr-filter-webpack-plugin');
// ...
{
plugins: [
// Disable HMR for `worker-loader` and `service-worker-loader`
new HotModuleReplacementFilterPlugin((compilation) => {
const {
name
} = compilation.compiler;
return name && name.includes('worker');
}),
new webpack.HotModuleReplacementPlugin()
]
}