Skip to content

Commit

Permalink
Merge pull request #80 from katjad/fix-hotload
Browse files Browse the repository at this point in the history
make react hot reloading work again
  • Loading branch information
katjad authored Sep 4, 2017
2 parents 98d80dc + 4db8fda commit f6acefb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const port = 3000;
const compiler = webpack(config)
app.use(express.static(path.join(__dirname + '/public')));

app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.publicPath }))
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: config.output.path }))
app.use(webpackHotMiddleware(compiler));

app.use(routes);
Expand Down
40 changes: 24 additions & 16 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,15 @@ var cssConfig = isProd ? cssProd : cssDev

console.log(cssConfig, isProd);

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

plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.ProvidePlugin({
'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
}),
new HtmlWebpackPlugin({
let pluginsProd = [ new HtmlWebpackPlugin({
title: 'JavaScript tools and resources',
minify: {
collapseWhitespace: true
Expand All @@ -43,7 +35,23 @@ module.exports = {
disable: !isProd,
allChunks: true
})
]

const plugins = isProd ? pluginsCommon.concat(pluginsProd) : pluginsCommon


module.exports = {
entry: [
'webpack-hot-middleware/client',
'./src/index.js'
],
output: {
path: path.join(__dirname,'public'),
publicPath: path.join(__dirname, 'public'),
filename: 'bundle.js'
},

plugins: plugins,
module: {
rules: [
{
Expand Down

0 comments on commit f6acefb

Please sign in to comment.