nuxt@2.4.3webpack
一、安裝UglifyJsPluginweb
yarn add UglifyJsPlugin -D or npm install UglifyJsPlugin -D
二、編輯nuxt.confignpm
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 }) ) } } }