const CompressionWebpackPlugin = require('compression-webpack-plugin'); const port = process.env.port || process.env.npm_config_port || 9103 // dev port const productionGzipExtensions = ['js','css','less'] module.exports = { publicPath: process.env.VUE_APP_PATH, outputDir: 'dist', assetsDir: 'static', productionSourceMap: false, transpileDependencies: ['vant'], // 需要兼容IE10要放开这个 devServer: { port: port, open: true, host: '0.0.0.0', overlay: { warnings: false, errors: true }, proxy: { '/alipayapi': { target: process.env.VUE_APP_BASE_URL, changeOrigin: true, pathRewrite: { '^/alipayapi': '' } } } }, chainWebpack: config => { config.plugin('html').tap(options => { options[0].title = '浙里学车生活号'; return options; }); if (process.env.NODE_ENV === 'production') { config.plugin('compressionPlugin').use(new CompressionWebpackPlugin({ filename: '[path].gz[query]', algorithm: 'gzip', test: new RegExp( '\\.(' +productionGzipExtensions.join('|') + ')$' ), threshold: 10240, // deleteOriginalAssets:true, //删除源文件,不建议 minRatio: 0.8 })); } } }