Support NODE_ENV in webpack (#10245)
Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
0bba3f9cf6
commit
9ed4aeeaf1
1 changed files with 11 additions and 2 deletions
|
@ -19,8 +19,10 @@ for (const path of glob('web_src/less/themes/*.less')) {
|
||||||
themes[parse(path).name] = [path];
|
themes[parse(path).name] = [path];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isProduction = process.env.NODE_ENV !== 'development';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: 'production',
|
mode: isProduction ? 'production' : 'development',
|
||||||
entry: {
|
entry: {
|
||||||
index: [
|
index: [
|
||||||
resolve(__dirname, 'web_src/js/index.js'),
|
resolve(__dirname, 'web_src/js/index.js'),
|
||||||
|
@ -42,7 +44,7 @@ module.exports = {
|
||||||
chunkFilename: 'js/[name].js',
|
chunkFilename: 'js/[name].js',
|
||||||
},
|
},
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: true,
|
minimize: isProduction,
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
|
@ -96,6 +98,7 @@ module.exports = {
|
||||||
resolve(__dirname, 'package-lock.json'),
|
resolve(__dirname, 'package-lock.json'),
|
||||||
resolve(__dirname, 'webpack.config.js'),
|
resolve(__dirname, 'webpack.config.js'),
|
||||||
].map((path) => statSync(path).mtime.getTime()).join(':'),
|
].map((path) => statSync(path).mtime.getTime()).join(':'),
|
||||||
|
sourceMaps: true,
|
||||||
presets: [
|
presets: [
|
||||||
[
|
[
|
||||||
'@babel/preset-env',
|
'@babel/preset-env',
|
||||||
|
@ -190,6 +193,7 @@ module.exports = {
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
performance: {
|
performance: {
|
||||||
|
hints: isProduction ? 'warning' : false,
|
||||||
maxEntrypointSize: 512000,
|
maxEntrypointSize: 512000,
|
||||||
maxAssetSize: 512000,
|
maxAssetSize: 512000,
|
||||||
assetFilter: (filename) => {
|
assetFilter: (filename) => {
|
||||||
|
@ -201,4 +205,9 @@ module.exports = {
|
||||||
resolve: {
|
resolve: {
|
||||||
symlinks: false,
|
symlinks: false,
|
||||||
},
|
},
|
||||||
|
watchOptions: {
|
||||||
|
ignored: [
|
||||||
|
'node_modules/**',
|
||||||
|
],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue