Install webpack-dev-middleware via npm
npm i -D webpack-dev-middleware webpack-hot-middleware
Modify webpack.config.js
Add webpack-hot-middleware/client to each items defined in "entry"
Add new webpack.HotModuleReplacementPlugin() to "plugins"
module.export...
To make a module eligible for Hot Module Replacement (HMR), the simplest way is to add module.hot.accept() inside the module, like this:
// ...
if(module.hot) {
module.hot.accept(); // This will make current module replaceable
}
Install webpack-dev-server via npm.
npm i -D webpack-dev-server
Configure webpack-dev-server by adding server.js.
// server.js
var webpack = require("webpack");
var WebpackDevServer = require("webpack-dev-server");
var config = require("./webpack.dev.config...