vue3 混淆

2022-04-25 18:13:05 浏览数 (1)

代码语言:javascript复制
configureWebpack: (config) => {
        //  引入uglifyjs-webpack-plugin
        let UglifyPlugin = require('uglifyjs-webpack-plugin');

        if (process.env.NODE_ENV == 'production') {
            // 为生产环境修改配置
            config.mode = 'production'
            // 将每个依赖包打包成单独的js文件
            let optimization = {
                minimizer: [new UglifyPlugin({
                    uglifyOptions: {
                        warnings: false,
                        compress: {
                            drop_console: true,
                            drop_debugger: false,
                            pure_funcs: ['console.log']
                        }
                    }
                })]
            }
            Object.assign(config, {
                optimization
            })
        } else {
            // 为开发环境修改配置
            config.mode = 'development'
        }
    }

0 人点赞