-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
78 lines (78 loc) · 2.29 KB
/
vue.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const path = require("path");
const { name } = require("./package");
const config = require('../config/env-configs').config;
// gzip压缩
const CompressionWebpackPlugin = require("compression-webpack-plugin");
// 分析包大小
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
/**
* You will need to set publicPath if you plan to deploy your site under a sub path,
* for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
* then publicPath should be set to "/bar/".
* In most cases please use '/' !!!
* Detail: https://cli.vuejs.org/config/#publicpath
*/
// publicPath: config.admin.entryPath + ':' + config.admin.entryPort,
outputDir: "dist",
assetsDir: "static",
filenameHashing: true,
productionSourceMap: false,
// tweak internal webpack configuration.
// see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
devServer: {
// host: '0.0.0.0',
hot: true,
disableHostCheck: true,
// port: config.admin.entryPort,
overlay: {
warnings: false,
errors: true
},
headers: {
"Access-Control-Allow-Origin": "*"
}
},
css: {
loaderOptions: {
scss: {
prependData: `@import "~@/assets/css/variables/variables.scss";`
}
}
},
// 自定义webpack配置
configureWebpack: {
resolve: {
alias: {
"@": resolve("src")
}
},
// 把子应用打包成 umd 库格式
output: {
library: `${name}-[name]`,
libraryTarget: "umd",
jsonpFunction: `webpackJsonp_${name}`
},
// gzip
plugins: [
new CompressionWebpackPlugin({
filename: "[path].gz[query]", //目标资源名称
algorithm: "gzip",
test: /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i, //处理所有匹配此 {RegExp} 的资源
threshold: 10240,//只处理比这个值大的资源。按字节计算(楼主设置10K以上进行压缩)
minRatio: 0.8 //只有压缩率比这个值小的资源才会被处理
}),
// 分析包大小
// new BundleAnalyzerPlugin()
],
externals: {
'vue': 'Vue',
'vuex': 'Vuex',
'vue-router': 'VueRouter',
'element-ui': 'ELEMENT',
}
}
};