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; #静态压缩

}

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM