Skip to content

Commit f6acefb

Browse files
authored
Merge pull request #80 from katjad/fix-hotload
make react hot reloading work again
2 parents 98d80dc + 4db8fda commit f6acefb

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const port = 3000;
1616
const compiler = webpack(config)
1717
app.use(express.static(path.join(__dirname + '/public')));
1818

19-
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }))
19+
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.path }))
2020
app.use(webpackHotMiddleware(compiler));
2121

2222
app.use(routes);

webpack.config.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,15 @@ var cssConfig = isProd ? cssProd : cssDev
1414

1515
console.log(cssConfig, isProd);
1616

17-
module.exports = {
18-
entry: [
19-
'webpack-hot-middleware/client',
20-
'./src/index.js'
21-
],
22-
output: {
23-
path: path.join(__dirname,'public'),
24-
filename: 'bundle.js'
25-
},
17+
let pluginsCommon = [
18+
new webpack.HotModuleReplacementPlugin(),
19+
new webpack.NoEmitOnErrorsPlugin(),
20+
new webpack.ProvidePlugin({
21+
'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
22+
})
23+
]
2624

27-
plugins: [
28-
new webpack.HotModuleReplacementPlugin(),
29-
new webpack.NoEmitOnErrorsPlugin(),
30-
new webpack.ProvidePlugin({
31-
'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
32-
}),
33-
new HtmlWebpackPlugin({
25+
let pluginsProd = [ new HtmlWebpackPlugin({
3426
title: 'JavaScript tools and resources',
3527
minify: {
3628
collapseWhitespace: true
@@ -43,7 +35,23 @@ module.exports = {
4335
disable: !isProd,
4436
allChunks: true
4537
})
38+
]
39+
40+
const plugins = isProd ? pluginsCommon.concat(pluginsProd) : pluginsCommon
41+
42+
43+
module.exports = {
44+
entry: [
45+
'webpack-hot-middleware/client',
46+
'./src/index.js'
4647
],
48+
output: {
49+
path: path.join(__dirname,'public'),
50+
publicPath: path.join(__dirname, 'public'),
51+
filename: 'bundle.js'
52+
},
53+
54+
plugins: plugins,
4755
module: {
4856
rules: [
4957
{

0 commit comments

Comments
 (0)