-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
84 lines (80 loc) · 2.4 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
79
80
81
82
83
84
module.exports = {
assetsDir: "static",
devServer: {
proxy: {
"/coperate": {
target: "http://targetHost.com",
ws: true,
changeOrigin: true,
// https://lvyongbo.gitbooks.io/http-proxy-middleware/content/log-level.html
logLevel: "debug",
pathRewrite: {
"^/coperate": "/coperate",
},
},
},
},
// https://cli.vuejs.org/zh/config/#publicpath
publicPath: "/childHost/",
configureWebpack: {
plugins: [],
},
// 更细粒度的控制 Vue CLI 内部的 webpack 配置
chainWebpack: (config) => {
const oneOfsMap = config.module.rule("scss").oneOfs.store;
oneOfsMap.forEach((item) => {
item
.use("sass-resources-loader")
.loader("sass-resources-loader")
.options({
// Provide path to the file with resources
resources: ["./src/assets/scss/index.scss"],
})
.end();
});
// chunks 构建策略
// splitChunks (webpack4 才有)
// 查看默认的 webpack 版本,https://github.com/vuejs/vue-cli/blob/master/packages/@vue/cli-service/package.json
config.optimization.splitChunks({
// cacheGroups: {
// // 创建一个 commons chunk,其中包括所有入口(entry points)共享的代码
// common: {
// name: "common",
// chunks: "initial",
// minChunks: 2,
// maxInitialRequests: 5,
// minSize: 0,
// priority: 1,
// reuseExistingChunk: true
// },
// vendors: {
// name: "chunk-vendors",
// test: /[\\/]node_modules[\\/]/,
// /** 抽取哪些资源
// * @param chunks all; async 异步 按需; initial 默认 */
// chunks: "all",
// /** 抽取优先级 */
// priority: 2,
// reuseExistingChunk: true,
// enforce: true
// },
// vant: {
// name: "chunk-vant",
// test: /[\\/]node_modules[\\/]vant[\\/]/,
// chunks: "all",
// priority: 3,
// reuseExistingChunk: true,
// enforce: true
// },
// videojs: {
// name: "chunk-videojs",
// test: /[\\/]node_modules[\\/]video.js[\\/]/,
// chunks: "all",
// priority: 4,
// reuseExistingChunk: true,
// enforce: true
// }
// }
});
},
};