diff --git a/dev.js b/dev.js index bb0d52c..f8e10d8 100644 --- a/dev.js +++ b/dev.js @@ -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); diff --git a/webpack.config.js b/webpack.config.js index e37e111..5f74c95 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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 @@ -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: [ {