Optimize build configuration.

This commit is contained in:
CismonX 2021-05-25 12:17:36 +08:00
parent 1dbafb6c97
commit 6cff7138f0
Signed by: cismonx
GPG Key ID: 3094873E29A482FB
2 changed files with 7 additions and 3 deletions

View File

@ -7,7 +7,6 @@
*/ */
{ {
"compilerOptions": { "compilerOptions": {
"module": "CommonJS",
"target": "ES2019", "target": "ES2019",
"outDir": "out", "outDir": "out",
"esModuleInterop": true, "esModuleInterop": true,

View File

@ -19,13 +19,15 @@ const config: webpack.Configuration = {
output: { output: {
path: path.resolve(__dirname, 'out'), path: path.resolve(__dirname, 'out'),
filename: 'extension.js', filename: 'extension.js',
libraryTarget: 'commonjs2', library: {
type: "commonjs2",
},
devtoolModuleFilenameTemplate: '../[resource-path]', devtoolModuleFilenameTemplate: '../[resource-path]',
}, },
devtool: isProduction ? false : 'source-map', devtool: isProduction ? false : 'source-map',
optimization: { optimization: {
concatenateModules: true, concatenateModules: true,
minimize: true, minimize: isProduction,
minimizer: [ minimizer: [
new TerserPlugin({ new TerserPlugin({
extractComments: false, extractComments: false,
@ -39,6 +41,9 @@ const config: webpack.Configuration = {
}, },
mangle: { mangle: {
module: true, module: true,
properties: {
regex: /^_/,
},
}, },
}, },
}), }),