您的位置:首页 > 教育 > 培训 > webpack terser-webpack-plugin 不打包注释及log

webpack terser-webpack-plugin 不打包注释及log

2025/2/25 1:49:40 来源:https://blog.csdn.net/Frazier1995/article/details/140322086  浏览:    关键词:webpack terser-webpack-plugin 不打包注释及log

踩坑记录:注意 terser-webpack-plugin": "^4.2.3" 对应着webpack4及版本一下的,5点多版本的对应webpack5,版本不对会报ERROR TypeError: Cannot read property 'javascript' of undefined

1.安装三方包
npm install terser-webpack-plugin2.在vue.config.js中配置
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {configureWebpack: {optimization: {minimize: true,//为了不影响dev时的构建速度minimizer: [new TerserPlugin({parallel: true,//使用多进程并发运行以提高构建速度 Boolean|Number 默认值: true  terserOptions: {compress: {drop_console: true,//移除所有console相关代码;drop_debugger: true,//移除自动断点功能;pure_funcs: ["console.log", "console.error"],//配置移除指定的指令,如console.log,alert等},format: {comments: false,//删除注释},},extractComments: false,//是否将注释剥离到单独的文件中})]}}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com