From a40aaf1c89d2a65b6bb397d3e1cc3621dcebfc15 Mon Sep 17 00:00:00 2001 From: weiserhei Date: Tue, 8 May 2018 02:03:37 +0200 Subject: [PATCH] move plugins declaration below production The current version is working fine on CentOS, but on Windows10 I encountered this problem: the `webpack.DefinePlugin` replaces `__ENV__` before the `env = "prod";` is executed. Resulting in a production build, but the global var is still set to "dev". --- webpack.config.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 9aaabbe8..c5b77a93 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,14 +16,7 @@ var env = 'dev', time = Date.now(), devtool = 'eval', mode = 'development', - stats = 'minimal', - plugins = [ - //new webpack.NoErrorsPlugin(), - new webpack.DefinePlugin({ - __ENV__: JSON.stringify(env), - ___BUILD_TIME___: time - }) - ]; + stats = 'minimal'; // Production environment if(PROD) { @@ -34,6 +27,14 @@ if(PROD) { outputPath = __dirname + '/build/public/assets/js'; } +var plugins = [ + //new webpack.NoErrorsPlugin(), + new webpack.DefinePlugin({ + __ENV__: JSON.stringify(env), + ___BUILD_TIME___: time + }) +]; + console.log('Webpack build - ENV: ' + env + ' V: ' + time); console.log(' - outputPath ', outputPath); console.log(' - includePath ', includePath);