diff --git a/lib/build.js b/lib/build.js index 2898a991..7cf4b0ee 100644 --- a/lib/build.js +++ b/lib/build.js @@ -68,8 +68,14 @@ function webpackConfig(dir, additionalConfig) { defineEnv['process.env.' + key] = JSON.stringify(envConfig[key]); }); + // Keep the same NODE_ENV if it was specified + var nodeEnv = process.env.NODE_ENV || 'production' + + // Set webpack mode based on the nodeEnv + var webpackMode = ['production', 'development'].includes(nodeEnv) ? nodeEnv : 'none' + var webpackConfig = { - mode: 'production', + mode: webpackMode, resolve: { extensions: ['.wasm', '.mjs', '.js', '.json', '.ts'] }, @@ -99,6 +105,9 @@ function webpackConfig(dir, additionalConfig) { filename: '[name].js', libraryTarget: 'commonjs' }, + optimization: { + nodeEnv + }, devtool: false }; fs.readdirSync(dirPath).forEach(function(file) {