一、Gzip
(1)vue打包出现警告:Conflict: Multiple assets emit different content to the same filename assets/js/.gz
找到问题定位filename:属性filename: ‘[path].gz[query]’。
google最终找到原因是因为compression-webpack-plugin升级了
“compression-webpack-plugin”: “^6.1.1”,
这时候需要修改filename的设置为
filename: ‘[path][base].gz’,
在webpack.prod.conf.js中if (config.build.productionGzip) {
const CompressionWebpackPlugin = require(“compression-webpack-plugin”);
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
filename: “[path][base].gz]”,
algorithm: “gzip”,
test: new RegExp(
“\.(” + config.build.productionGzipExtensions.join("|") + “)$”
),
threshold: 10240,
minRatio: 0.8,
deleteOriginalAssets: false, // 删除原文件
})
);
}