Last active
February 6, 2018 04:39
-
-
Save caseyWebb/a5fdd929638f961ee673581e7d68ddb1 to your computer and use it in GitHub Desktop.
Webpack HMR Bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { log } from './logger.js' | |
log() | |
module.hot.accept('./logger.js', () => log()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function log() { | |
// toggle these, they should be printed to the screen one after another | |
document.body.innerText += 'foo\n' | |
// document.body.innerText += 'bar\n' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"license": "MIT", | |
"dependencies": { | |
"webpack": "^3.10.0", | |
"webpack-dev-server": "^2.11.1" | |
}, | |
"scripts": { | |
"start": "webpack-dev-server --hot" | |
}, | |
"devDependencies": { | |
"html-webpack-plugin": "^2.30.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const { HotModuleReplacementPlugin, NamedModulesPlugin } = require('webpack') | |
const HtmlWebpackPlugin = require('html-webpack-plugin') | |
module.exports = { | |
context: __dirname, | |
entry: { | |
app: './app.js' | |
}, | |
output: { | |
filename: 'bundle.js', | |
path: __dirname + '/dist', | |
publicPath: '/' | |
}, | |
plugins: [ | |
// new NamedModulesPlugin(), // causes error | |
new HotModuleReplacementPlugin(), | |
new HtmlWebpackPlugin() | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment