if your webpack4 or react project can consider using this for hot updates react-hot-loader
, just report one layer in the router location, for example, export default hot (module) (AppRouter)
,
your method requires an additional line of code in entry. According to my own erection, I need ['webpack-dev-server/client', _ dirname + "/ src/main.js],
.
or execute this method in the entry file
if(module.hot)
{
module.hot.accept();
}
my configuration:
package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "webpack --watch",
"start": "webpack-dev-server --open",
"build": "webpack --env.production"
}
webapck.config.js
devServer: {
host: '0.0.0.0',
useLocalIp: true,
contentBase: path.resolve(__dirname, 'dist'),
openPage: "webpack-dev-server",
compress: true,
port: 9000,
open: true,
}
did you find the problem? I encountered this, too.
my dev-server configuration
const hotMiddleware = require('webpack-hot-middleware')(compiler, {
log: false,
heartbeat: 2000
})
app.use(hotMiddleware)
dev-client configuration
'use strict'
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
hotClient.subscribe(function (event) {
if (event.action === 'reload') {
window.location.reload()
}
})