vue 每次編譯都會(huì)將編譯后的文件緩存在 node_modules /.cache 里面,因此需要在 vue.config.js 配置取消緩存文章來源地址http://www.zghlxwxcb.cn/news/detail-718011.html
compression-webpack-plugin 禁止緩存
const CompressionPlugin = require("compression-webpack-plugin");
module.exports = {
plugins: [
new CompressionPlugin({
cache: false, // 取消緩存
algorithm: "gzip",
filename: "[path].gz[query]",
test: /\.(js|css|woff|woff2|json|txt|html|ico|svg)(\?.*)?$/i, // 要壓縮的文件
threshold: 10240, // 壓縮超過10k的數(shù)據(jù)
deleteOriginalAssets: false, // 不刪除壓縮前的文件,如果瀏覽器不支持Gzip,則會(huì)加載源文件
minRatio: 0.8, // 壓縮比大于0.8的文件將不會(huì)被壓縮
}),
],
}
文章來源:http://www.zghlxwxcb.cn/news/detail-718011.html
到了這里,關(guān)于解決 vue 項(xiàng)目開發(fā)越久 node_modules包越大的問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!