From 3702dfe5dcb5c4fdeb03fcd3025f5a5ae39232be Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 14 Nov 2018 12:00:12 +0000 Subject: [PATCH] refactor: add node_env in webpack DefinePlugin (#4330) --- packages/webpack/src/config/base.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/webpack/src/config/base.js b/packages/webpack/src/config/base.js index 519f1c0425..b1cd5b5fce 100644 --- a/packages/webpack/src/config/base.js +++ b/packages/webpack/src/config/base.js @@ -25,6 +25,7 @@ export default class WebpackBaseConfig { this.options = builder.context.options this.spinner = builder.spinner this.loaders = this.options.build.loaders + this.buildMode = this.options.dev ? 'development' : 'production' } get colors() { @@ -85,6 +86,7 @@ export default class WebpackBaseConfig { env() { const env = { + 'process.env.NODE_ENV': JSON.stringify(this.buildMode), 'process.mode': JSON.stringify(this.options.mode), 'process.static': this.isStatic } @@ -319,7 +321,7 @@ export default class WebpackBaseConfig { const webpackModulesDir = ['node_modules'].concat(this.options.modulesDir) const config = { name: this.name, - mode: this.options.dev ? 'development' : 'production', + mode: this.buildMode, devtool: this.devtool(), optimization: this.optimization(), output: this.output(),