Skip to content

Commit 96015d7

Browse files
wip(build): handle --env noSourceMap flag
1 parent 9920678 commit 96015d7

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

build/webpack.config.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const configure = ({name, vueVersion}) => (env = {}, { mode = 'production', conf
2828
const {
2929
targetsBrowsers = 'defaults',
3030
noPresetEnv = !isProd,
31-
noCompress = !isProd
31+
noCompress = !isProd,
32+
noSourceMap = !isProd,
3233
} = env;
3334

3435
const genSourcemap = false;
@@ -61,7 +62,7 @@ const configure = ({name, vueVersion}) => (env = {}, { mode = 'production', conf
6162
},
6263

6364
// doc: https://webpack.js.org/configuration/devtool/#devtool
64-
devtool: isProd ? 'source-map' : 'cheap-source-map',
65+
devtool: noSourceMap ? false : isProd ? 'source-map' : 'cheap-source-map',
6566

6667
performance: { hints: false },
6768

@@ -128,22 +129,25 @@ const configure = ({name, vueVersion}) => (env = {}, { mode = 'production', conf
128129
] : [],
129130

130131
...isProd ? [
131-
new CompressionPlugin({
132-
filename: "[path][base].br",
133-
algorithm: "brotliCompress",
134-
compressionOptions: {
135-
params: {
136-
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
132+
133+
...!noCompress ? [
134+
new CompressionPlugin({
135+
filename: "[path][base].br",
136+
algorithm: "brotliCompress",
137+
compressionOptions: {
138+
params: {
139+
[zlib.constants.BROTLI_PARAM_QUALITY]: zlib.constants.BROTLI_MAX_QUALITY,
140+
},
137141
},
138-
},
139-
}),
140-
new CompressionPlugin({
141-
filename: "[path][base].gz",
142-
algorithm: "gzip",
143-
compressionOptions: {
144-
level: 9,
145-
},
146-
}),
142+
}),
143+
new CompressionPlugin({
144+
filename: "[path][base].gz",
145+
algorithm: "gzip",
146+
compressionOptions: {
147+
level: 9,
148+
},
149+
}),
150+
] : [],
147151
new DuplicatePackageCheckerPlugin(),
148152
new BundleAnalyzerPlugin({
149153
// doc: https://github.com/webpack-contrib/webpack-bundle-analyzer#options-for-plugin

0 commit comments

Comments
 (0)