Commit d03cb303 authored by 张伯涛's avatar 张伯涛

项目打包gzip压缩,部署后线上更快

parent 3128ae02
# just a flag
ENV = 'test'
ENV = 'production'
# 测试环境
# base api
......
......@@ -8,6 +8,8 @@ const D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate())
const h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours())
const m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes())
const now = Y + M + D + h + m
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
function resolve(dir) {
return path.join(__dirname, dir)
}
......@@ -67,6 +69,15 @@ module.exports = {
},
configureWebpack: {
name: name,
plugins: [
new CompressionWebpackPlugin({
filename: '[path].gz[query]', // 提示compression-webpack-plugin@3.0.0的话asset改为filename
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
],
resolve: {
alias: {
'@': resolve('src')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment