View Code? Open in Web Editor
NEW
Three ways to set up your webpack hot module replacement: webpack-dev-server CLI, webpack-dev-server API, and express with webpack-hot-middleware.
Home Page: https://www.javascriptstuff.com/3-ways-webpack-hmr
JavaScript 96.33%
HTML 3.67%
webpack-hmr-3-ways's Issues
Thanks @ahfarmer for your posts and repos.
You mention in the source code
// console.log statements are reprinted on every reload.
Can you explain if I replace console.log with document.writeln it doesn't reload?
When I delete "document.body.appendChild(sideEffectNode);", and re-add this line, the hmr does not work. What should I do to make hmr work under any condition?
Should I detect NODE_ENV
and run the middleware conditionally? Something like this:
if ( process . env . NODE_ENV != 'production' ) {
app . use ( webpackDevMiddleware ) ;
app . use ( webpackHotMiddleware ) ;
}
Or is there a better approach?