From b8f3264bacc50c1d34f0aeb7f70df6070e675b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=A0=C9=AA=E1=B4=84=E1=B4=9B=E1=B4=8F=CA=80=20=CA=99?= =?UTF-8?q?=E1=B4=8A=E1=B4=87=CA=9F=E1=B4=8B=CA=9C=E1=B4=8F=CA=9F=E1=B4=8D?= Date: Thu, 11 Aug 2016 18:01:52 +0200 Subject: [PATCH] Allow changing the dev server configuration I was spending around one hour trying to troubleshot why my devServer config in webpack.config.js didn't work. Turns out, those options are not applied when starting the dev server. This change implements so it's possible to customize the dev server, if the devServer key is set in the webpack.config.js --- dev.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dev.js b/dev.js index a20789f..ac5655f 100644 --- a/dev.js +++ b/dev.js @@ -17,7 +17,7 @@ module.exports = function (config, options) { var compiler = webpack(config) - var server = new WebpackDevServer(compiler, { + var devServerConfig = { contentBase: config.output.path, historyApiFallback: true, @@ -28,7 +28,13 @@ module.exports = function (config, options) { quiet: options.quiet, stats: 'errors-only', hot: true - }) + } + + if (config.devServer) { + devServerConfig = Object.assign(devServerConfig, config.devServer) + } + + var server = new WebpackDevServer(compiler, devServerConfig) server.listen(options.port, '0.0.0.0', function () { console.log('webpack-dev-server http://0.0.0.0:%d/', options.port)