Three ways to set up your webpack hot module replacement: webpack-dev-server CLI, webpack-dev-server API, and express with webpack-hot-middleware.
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
middleware ⬆️ update to webpack 3 Jan 12, 2018
server-api ⬆️ update to webpack 3 Jan 12, 2018
server-cli ⬆️ update to webpack 3 Jan 12, 2018
.gitignore update to webpack 2 Feb 8, 2017 ⬆️ update to webpack 3 Jan 12, 2018

HMR 3 Ways

There are 3 ways to use Webpack HMR. This repository contains a minimal example of each way. In order from simplest to most complex:

Here is a short discussion on how to pick the method you want to use.

About the Code

The browser javascript code within each directory is the same. There are 3 files:

js/index.js: Entry point. require()s the other 2 files, box-creator.js and math-doer.js.

js/math-doer.js: An extremely simple file to illustrate that dependencies are automatically updated by HMR.

js/box-creator.js: An example of a dependency that has side effects, with an example of how to use to handle such side effects.