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

打包时gzip压缩

parent ad0c4ea3
# just a flag # just a flag
ENV = 'test' ENV = 'test'
NODE_ENV= 'production'
# 测试环境 # 测试环境
# base api # base api
VUE_APP_BASE_API = 'http://192.144.239.97:20075/' VUE_APP_BASE_API = 'http://192.144.239.97:20075/'
...@@ -54,7 +54,9 @@ ...@@ -54,7 +54,9 @@
"babel-core": "7.0.0-bridge.0", "babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1", "babel-eslint": "10.0.1",
"chalk": "2.4.2", "chalk": "2.4.2",
"compression-webpack-plugin": "^1.1.12",
"connect": "3.6.6", "connect": "3.6.6",
"crypto-js": "4.1.1",
"eslint": "5.15.3", "eslint": "5.15.3",
"eslint-plugin-vue": "5.2.2", "eslint-plugin-vue": "5.2.2",
"html-webpack-plugin": "3.2.0", "html-webpack-plugin": "3.2.0",
...@@ -68,8 +70,7 @@ ...@@ -68,8 +70,7 @@
"stylus-loader": "^3.0.2", "stylus-loader": "^3.0.2",
"svg-sprite-loader": "4.1.3", "svg-sprite-loader": "4.1.3",
"svgo": "1.2.2", "svgo": "1.2.2",
"vue-template-compiler": "2.6.10", "vue-template-compiler": "2.6.10"
"crypto-js": "4.1.1"
}, },
"engines": { "engines": {
"node": ">=8.9", "node": ">=8.9",
......
...@@ -14,6 +14,8 @@ function resolve(dir) { ...@@ -14,6 +14,8 @@ function resolve(dir) {
const name = defaultSettings.title || 'vue Admin Template' // page title const name = defaultSettings.title || 'vue Admin Template' // page title
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
const port = process.env.port || process.env.npm_config_port || 8080 // dev port const port = process.env.port || process.env.npm_config_port || 8080 // dev port
...@@ -47,8 +49,8 @@ module.exports = { ...@@ -47,8 +49,8 @@ module.exports = {
// }, // },
proxy: { proxy: {
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
target: `http://49.232.167.247:20014/`, // 线上 // target: `http://49.232.167.247:20014/`, // 线上
// target: `http://192.168.1.30:8082/`, target: `http://192.168.1.30:8001/`,
// changeOrigin: true, // changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''
...@@ -60,6 +62,15 @@ module.exports = { ...@@ -60,6 +62,15 @@ module.exports = {
// provide the app's title in webpack's name field, so that // provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title. // it can be accessed in index.html to inject the correct title.
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