npm i compression-webpack-plugin@5.0.1 -D
修改 vue.config.js
const CompressionWebpackPlugin = require("compression-webpack-plugin")
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
productionSourceMap: false,
assetsDir: 'assets',
lintOnSave: false, //这里禁止使用eslint-loader
pluginOptions: {
moment: {
locales: ['moment'],
},
},
configureWebpack: config => {
if (isProduction) {
// 用cdn方式引入
return {
plugins: [new CompressionWebpackPlugin({
test: /\.(js|css)(\?.*)?$/i,
threshold: 10240,
deleteOriginalAssets: false
})]
};
}
},
}