nuxt.js@2.x 项目打包时清除console、debugger、warnings

nuxt@2.4.3
1、安装UglifyJsPlugin
yarn add UglifyJsPlugin -D
or
npm install UglifyJsPlugin -D
2、编辑nuxt.config
const UglifyJsPlugin = require(‘uglifyjs-webpack-plugin’)
build: {
extend(config, ctx) {
if(!ctx.isDev&&ctx.isClient){
config.plugins.push(
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false,
drop_console: true,
drop_debugger:true
},
},
sourceMap: true,
cache: true,
parallel: true
})
)
}
}
}

评论

《“nuxt.js@2.x 项目打包时清除console、debugger、warnings”》 有 1 条评论

  1. arche 的头像
    arche

    安装UglifyJsPlugin 404

回复 arche 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理