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