-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
84 lines (68 loc) · 2.26 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
// ------------------------------------------------------------------------------
// name: vue.config.js
// author: 喵大斯( h5devs.com/h5devs.net )
// created: 2019/4/23 21:00
// ------------------------------------------------------------------------------
const path = require('path');
const DEBUG = process.env.NODE_ENV === 'development';
function resolve(...dir) {
return path.join(__dirname, ...dir);
}
// 排除所有不必要的模块,让宿主环境去安排必要的第三方包
const regexp = /^(lodash|core-js|axios|element-ui|vue)/i;
const externals = DEBUG ? '' : [regexp];
module.exports = {
publicPath: DEBUG ? '/' : './',
outputDir: 'dist',
assetsDir: '',
productionSourceMap: false,
// 调试配置
devServer: {
// 跨域配置
proxy: {
'/shop-api': {
target: 'http://test.api.blibao.com:8080',
changeOrigin: true,
secure: false,
pathRewrite: { '^/shop-api': '' }
},
'/member-user': {
target: 'http://test.api.blibao.com:8080',
changeOrigin: true,
secure: false
// pathRewrite: { '^/member-user': 'member-user' }
},
'/smo-api': {
target: 'http://test.blibao.com:10080',
changeOrigin: true,
secure: false
// pathRewrite: { '^/smo-api': 'smo-api' }
}
}
},
// 默认情况下 babel-loader 会忽略所有 node_modules 中的文件
// 此处列出 node_modules 中同样需要让 babel 转译的 esm 模块
transpileDependencies: [
'@mudas/*'
],
configureWebpack: {
entry: resolve('src/main.js'),
// 不分割任何模块
optimization: {
minimize: !DEBUG,
// 开发时爱怎么分割怎么分,少做点合并包的事应该会快点吧
splitChunks: DEBUG ? {} : false
},
// 排除外部库(如使用CDN或引用本地JS库)
externals
},
chainWebpack: (config) => {
// 输出到 dist,而非 dist/static
config.output.filename('[name].js');
// 增加资源识别路径(仍然不支持 style="background: url()" 的路径识别)
// config.module.rule('file').include.add('/demo/assets');
// 路径别名
config.resolve.alias.set('@', resolve('src'));
config.resolve.alias.set('@mudas/http', resolve('packages'));
}
};