.cache中的compression-webpack-plugin每次增加的空间,正好是整个node_modules增加的空间。
compression-webpack-plugin
npm i compression-webpack-plugin -D
配置
if (process.env.NODE_ENV ==='production'){ config.plugin('compressionPlugin') .use(new compressionWebpackPlugin({ // filename: '[path].gz[query]', algorithm: 'gzip', // test: /.(js|css|txt|html|ico|svg)(?.*)?$/i, test:/.(js|css|html|ttf|otf)(?.*)?$/i, threshold: 10240, minRatio: 0.8, deleteOriginalAssets: false })); }
configureWebpack: { // provide the app's title in webpack's name field, so that // it can be accessed in index.html to inject the correct title. name: name, resolve: { alias: { '@': resolve('src') } }, plugins: process.env.NODE_ENV === 'production' ? [ new CompressionWebpackPlugin({ algorithm: 'gzip', test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'), threshold: 10240, minRatio: 0.8 // deleteOriginalAssets: true// 压缩完是否保留原文件 }) ] : [] },