aboutsummaryrefslogtreecommitdiffstats
path: root/webpack.config.js
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-02-23 09:47:42 +0100
committerGitHub <noreply@github.com>2020-02-23 10:47:42 +0200
commit9ed4aeeaf10661156d61a6cac904d2b060663764 (patch)
tree4c622f029c968b5aba9691b0d1057c1e0187818b /webpack.config.js
parent0bba3f9cf60550c51f22860afcc1c3ebaba8dd9d (diff)
downloadgitea-9ed4aeeaf10661156d61a6cac904d2b060663764.tar.gz
gitea-9ed4aeeaf10661156d61a6cac904d2b060663764.zip
Support NODE_ENV in webpack (#10245)
Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'webpack.config.js')
-rw-r--r--webpack.config.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/webpack.config.js b/webpack.config.js
index c3d3ad88e0..4d2db5cf18 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -19,8 +19,10 @@ for (const path of glob('web_src/less/themes/*.less')) {
themes[parse(path).name] = [path];
}
+const isProduction = process.env.NODE_ENV !== 'development';
+
module.exports = {
- mode: 'production',
+ mode: isProduction ? 'production' : 'development',
entry: {
index: [
resolve(__dirname, 'web_src/js/index.js'),
@@ -42,7 +44,7 @@ module.exports = {
chunkFilename: 'js/[name].js',
},
optimization: {
- minimize: true,
+ minimize: isProduction,
minimizer: [
new TerserPlugin({
sourceMap: true,
@@ -96,6 +98,7 @@ module.exports = {
resolve(__dirname, 'package-lock.json'),
resolve(__dirname, 'webpack.config.js'),
].map((path) => statSync(path).mtime.getTime()).join(':'),
+ sourceMaps: true,
presets: [
[
'@babel/preset-env',
@@ -190,6 +193,7 @@ module.exports = {
}),
],
performance: {
+ hints: isProduction ? 'warning' : false,
maxEntrypointSize: 512000,
maxAssetSize: 512000,
assetFilter: (filename) => {
@@ -201,4 +205,9 @@ module.exports = {
resolve: {
symlinks: false,
},
+ watchOptions: {
+ ignored: [
+ 'node_modules/**',
+ ],
+ },
};