├── .gitignore ├── hello.js ├── README.md ├── index.js ├── index.html ├── webpack.config.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json -------------------------------------------------------------------------------- /hello.js: -------------------------------------------------------------------------------- 1 | const hello = () => 'hello world nice' 2 | export default hello -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # a minimum and pure example of **webpack hot module replacement** -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import hello from './hello.js' 2 | const div = document.createElement('div') 3 | div.innerHTML = hello() 4 | 5 | document.body.appendChild(div) 6 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Document 6 | 7 | 8 |
nice
9 | 10 | 11 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const webpack = require('webpack') 3 | module.exports = { 4 | entry: './index.js', 5 | output: { 6 | filename: 'bundle.js', 7 | path: path.join(__dirname, '/') 8 | }, 9 | devServer: { 10 | hot: true 11 | } 12 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ds-demo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "webpack-dev-server --hot --open" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "webpack": "^3.7.1", 14 | "webpack-dev-server": "^2.9.1" 15 | } 16 | } 17 | --------------------------------------------------------------------------------