vue打包去除日志

# 下载依赖

npm i -D terser-webpack-plugin
"terser-webpack-plugin": "^4.1.0",

# vue.config.js

const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
    configureWebpack: {
		optimization: {
			minimize: process.env.NODE_ENV === 'production',
			minimizer: [
				new TerserPlugin({
					terserOptions: {
						ecma: undefined,
						warnings: false,
						parse: {},
						compress: {
							drop_console: true,
							drop_debugger: true,
							pure_funcs: ['console.log'], // 移除console
						},
					},
				}),
			],
		},
	}
}
lastUpdate: 2/24/2023, 5:32:22 PM