1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| const TerserPlugin = require('terser-webpack-plugin');
|
| module.exports = {
| productionSourceMap: false, // 不生成 source map(可选,增强混淆效果)
| configureWebpack: {
| optimization: {
| minimizer: [
| new TerserPlugin({
| terserOptions: {
| compress: {
| drop_console: true, // 移除所有 console.*
| drop_debugger: true, // 移除 debugger
| pure_funcs: ['console.log'], // 如果你只想移除 console.log,可以用这个
| },
| mangle: true, // 混淆变量名(默认就是 true)
| keep_fnames: false, // 不保持函数名
| keep_classnames: false, // 不保持类名
| },
| }),
| ],
| },
| },
| };
|
|