Skip to content

Commit 9ed4aee

Browse files
silverwindlafrikslunny
authored
Support NODE_ENV in webpack (#10245)
Co-authored-by: Lauris BH <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 0bba3f9 commit 9ed4aee

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

webpack.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ for (const path of glob('web_src/less/themes/*.less')) {
1919
themes[parse(path).name] = [path];
2020
}
2121

22+
const isProduction = process.env.NODE_ENV !== 'development';
23+
2224
module.exports = {
23-
mode: 'production',
25+
mode: isProduction ? 'production' : 'development',
2426
entry: {
2527
index: [
2628
resolve(__dirname, 'web_src/js/index.js'),
@@ -42,7 +44,7 @@ module.exports = {
4244
chunkFilename: 'js/[name].js',
4345
},
4446
optimization: {
45-
minimize: true,
47+
minimize: isProduction,
4648
minimizer: [
4749
new TerserPlugin({
4850
sourceMap: true,
@@ -96,6 +98,7 @@ module.exports = {
9698
resolve(__dirname, 'package-lock.json'),
9799
resolve(__dirname, 'webpack.config.js'),
98100
].map((path) => statSync(path).mtime.getTime()).join(':'),
101+
sourceMaps: true,
99102
presets: [
100103
[
101104
'@babel/preset-env',
@@ -190,6 +193,7 @@ module.exports = {
190193
}),
191194
],
192195
performance: {
196+
hints: isProduction ? 'warning' : false,
193197
maxEntrypointSize: 512000,
194198
maxAssetSize: 512000,
195199
assetFilter: (filename) => {
@@ -201,4 +205,9 @@ module.exports = {
201205
resolve: {
202206
symlinks: false,
203207
},
208+
watchOptions: {
209+
ignored: [
210+
'node_modules/**',
211+
],
212+
},
204213
};

0 commit comments

Comments
 (0)