vue项目打包压缩

vue项目打包压缩

vue-cli-service build --report 打包完成会产生report.html 通过这个文件可以得知项目体积以及个个依赖大小,打包完成后开启nginx压缩

安装压缩包 npm i compression-webpack-plugin -D

vue.config.js里配置

configureWebpack: config => {

if (process.env.NODE_ENV === 'production') {

return {

plugins: [ new CompressionPlugin({

test: /.js$|.html$|\css|.jpg$|.png/, // 匹配文件名

threshold: 10240, // 对超过10k的文件进行压缩

deleteOriginalAssets: true // 是否删除原文件

})]

}

}

},

nginx 里面配置

location / {

root html\web;

index index.html;

gzip_static on; #静态压缩

}

 

 

一辈子说长不长,说短不短,努力做好两件事:第一件事爱生活,爱身边的人,爱自己;第二件事是好好学习,好好工作,实现自己的人生价值观,而不仅仅是为了赚钱
原文地址:https://www.cnblogs.com/dcyd/p/15679334.html