我想使用 Terser 插件压缩我的 js 文件。 这是我的依赖
"dependencies": {
"axios": "^0.26.0",
"core-js": "^3.6.5",
"terser-webpack-plugin": "^4.2.3",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuetify": "^2.4.0",
"vuex": "^3.6.0",
"webpack": "^4.46.0"
}
然后我创建了一个 webpack.config.js 来添加插件,如docs
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
};
当我运行我的项目时,它不会缩小我的 js 文件。另外,文档说我们应该
run webpack via your preferred method.
。如何运行 webpack?感谢所有帮助,谢谢。
你应该把这样的配置放在 vue.config.js 中:
module.exports = {
configureWebpack: {
optimization: {
minimize: true.
// etc...
}
}
}
比照。 文档