Skip to content

Commit 5fb6819

Browse files
author
Fabio Moyano
committed
Fix how NODE_ENV is being handled
If an specific NODE_ENV value is specified, let it pass through and set the mode accordingly. If a non-standard NODE_ENV is specified, let is pass through and set the webpack mode to none.
1 parent 5449ef1 commit 5fb6819

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/build.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ function webpackConfig(dir, additionalConfig) {
6868
defineEnv['process.env.' + key] = JSON.stringify(envConfig[key]);
6969
});
7070

71+
// Keep the same NODE_ENV if it was specified
72+
var nodeEnv = process.env.NODE_ENV || 'production'
73+
74+
// Set webpack mode based on the nodeEnv
75+
var webpackMode = ['production', 'development'].includes(nodeEnv) ? nodeEnv : 'none'
76+
7177
var webpackConfig = {
72-
mode: 'production',
78+
mode: webpackMode,
7379
resolve: {
7480
extensions: ['.wasm', '.mjs', '.js', '.json', '.ts']
7581
},
@@ -99,6 +105,9 @@ function webpackConfig(dir, additionalConfig) {
99105
filename: '[name].js',
100106
libraryTarget: 'commonjs'
101107
},
108+
optimization: {
109+
nodeEnv
110+
},
102111
devtool: false
103112
};
104113
fs.readdirSync(dirPath).forEach(function(file) {

0 commit comments

Comments
 (0)