vuejs 3.x项目使用terser-webpack-plugin 去除console 没有生效

vuejs版本 3.2.13

使用的是vue cli 4+

在vue.config.js 中的配置

因为vue项目内置了terser 所以不需要安装,直接引用
javascript 复制代码
const TerserPlugin = require('terser-webpack-plugin');
vue.config.js 中的配置
javascript 复制代码
module.exports = {
	//此处省略其他配置。。。
  configureWebpack: {
    plugins:[
	 	//此处省略其他配置。。。
  		new TerserPlugin({
		    parallel: true,
		    terserOptions: {
		      ecma: undefined,
		      warnings: false,
		      parse: {},
		      compress: {
		        drop_console: true,
		        drop_debugger: false,
		        pure_funcs: ['console.log'], // 移除console
		      },
		    },
		}),
	]
  },

  //此处省略其他配置。。。
}

最终参考的链接很棒👍

相关推荐
谷粒.20 小时前
Cypress vs Playwright vs Selenium:现代Web自动化测试框架深度评测
java·前端·网络·人工智能·python·selenium·测试工具
小飞侠在吗1 天前
vue props
前端·javascript·vue.js
DsirNg1 天前
页面栈溢出问题修复总结
前端·微信小程序
小徐_23331 天前
uni-app 也能远程调试?使用 PageSpy 打开调试的新大门!
前端·微信小程序·uni-app
大怪v1 天前
【Virtual World 03】上帝之手
前端·javascript
用户841794814561 天前
vxe-gantt 甘特图实现产品进度列表,自定义任务条样式和提示信息
vue.js
别叫我->学废了->lol在线等1 天前
演示 hasattr 和 ** 解包操作符
开发语言·前端·python
霍夫曼1 天前
UTC时间与本地时间转换问题
java·linux·服务器·前端·javascript
VX:Fegn08951 天前
计算机毕业设计|基于Java人力资源管理系统(源码+数据库+文档)
java·开发语言·数据库·vue.js·spring boot·后端·课程设计
DARLING Zero two♡1 天前
浏览器里跑 AI 语音转写?Whisper Web + cpolar让本地服务跑遍全网
前端·人工智能·whisper