terser is a compressed JS tool for ES6

insert image description here

https://www.npmjs.com/package/terser

uglify-es is no longer maintained, and uglify-js does not support ES6+.
terser is a branch of uglify-es, which mainly retains the compatibility with uglify and uglify-js@3.

npm install terser -g

terser [input files] [options]

terser-webpack-plugin

Use terser-webpack-plugin (npm i terser-webpack-plugin)
Because uglifyjs does not support es6 syntax, use terser-webpack-plugin instead of uglifyjs-webpack-plugin
terser-webpack-plugin The current latest version packaging will have compatibility issues, please use 4.x version
5.x of terser-webpack-plugin The version corresponds to webpack5.x, so if the packaging fails, pay attention to the next version.

在项目打包时去除console.log语句及debugger等。
第一次解决,首先想到了uglifyjs-webpack-plugin,因为没有成功就不赘述了,报的错似乎是不识别es6语法

terser-webpack-plugin插件Finally, the search found that vue-cli3.0 was used for optimization during the packaging process .

Since the terser-webpack-plugin has been used in the vue-cli tool, the terser-webpack-plugin can be directly introduced into the newly created project of the vue-cli without installation.

Guess you like

Origin blog.csdn.net/qq_39900031/article/details/131425314