diff --git a/lib/index.js b/lib/index.js index 316e117..30e3c63 100644 --- a/lib/index.js +++ b/lib/index.js @@ -60,8 +60,10 @@ var WebpackShellPlugin = function () { if (compiler.options.port) { this.options.port = compiler.options.port; - } else if (compiler.options.devServer.port) { - this.options.port = compiler.options.devServer.port; + } else if (compiler.options.devServer) { + if (compiler.options.devServer.port) { + this.options.port = compiler.options.devServer.port; + } } compiler.plugin('done', function (compilation) { diff --git a/src/webpack-browser-plugin.js b/src/webpack-browser-plugin.js index a2588bc..497bba3 100644 --- a/src/webpack-browser-plugin.js +++ b/src/webpack-browser-plugin.js @@ -25,8 +25,10 @@ export default class WebpackShellPlugin { apply(compiler) { if (compiler.options.port) { this.options.port = compiler.options.port; - } else if (compiler.options.devServer.port) { - this.options.port = compiler.options.devServer.port; + } else if (compiler.options.devServer) { + if (compiler.options.devServer.port) { + this.options.port = compiler.options.devServer.port; + } } compiler.plugin('done', (compilation) => {