-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
53 lines (52 loc) · 1.38 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
mode: 'production',
entry: path.resolve(__dirname,'dist/server/server.js'),
target:"node",
output: {
path: path.resolve(__dirname, 'output'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /specific-file\.js$/, // 匹配特定的文件
exclude: /node_modules/, // 排除 node_modules
use: {
loader: 'babel-loader',
options: {
presets: [
["@babel/preset-env", {
targets: { ie: '6' }, // 指定 ES3 兼容性
useBuiltIns: false,
shippedProposals: true,
}]
],
plugins: [
"@babel/plugin-transform-member-expression-literals",
"@babel/plugin-transform-property-literals",
"@babel/plugin-transform-reserved-words"
]
}
}
}
]
},
optimization: {
minimize: true, // 启用代码压缩
minimizer: [
new TerserPlugin({
terserOptions: {
compress: {
drop_console: true, // 删除所有 console 语句
drop_debugger: true, // 删除所有 debugger 语句
},
output: {
comments: false, // 删除所有注释
},
},
}),
],
},
};