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

打包gzip压缩,部署后线上运行更快

parent 5addf624
# just a flag # just a flag
ENV = 'test' ENV = 'production'
# 测试环境 # 测试环境
# base api # base api
......
...@@ -8,6 +8,8 @@ const D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) ...@@ -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 h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours())
const m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) const m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes())
const now = Y + M + D + h + m const now = Y + M + D + h + m
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
function resolve(dir) { function resolve(dir) {
return path.join(__dirname, dir) return path.join(__dirname, dir)
} }
...@@ -57,9 +59,9 @@ module.exports = { ...@@ -57,9 +59,9 @@ module.exports = {
open: false, open: false,
proxy: { proxy: {
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
// target: `http://192.168.1.46:8090/`, target: `http://49.232.167.247:20024/`,
target: `http://127.0.0.1:8090/`, // target: `http://192.168.10.108:8090/`, // 飞龙后端
// target: `http://192.168.1.21:8001/`, // 张宇 // target: `http://192.168.10.128:8090/`, // 奕霖后端
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''
} }
...@@ -68,6 +70,15 @@ module.exports = { ...@@ -68,6 +70,15 @@ module.exports = {
}, },
configureWebpack: { configureWebpack: {
name: name, 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: { resolve: {
alias: { alias: {
'@': resolve('src') '@': 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