-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
vue.config.js
80 lines (75 loc) · 1.67 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
const path = require('path')
const isProd = process.env.NODE_ENV === 'production'
const isLib = process.env.VUE_APP_BUILD_MODE === 'lib'
const resolve = dir => path.join(__dirname, dir)
const setChainWebpack = config => {
config.resolve.alias
.set('@', path.resolve('app'))
config.module
.rule('js')
.include
.add('/app')
.end()
.use('babel')
.loader('babel-loader')
if (isProd) {
config.performance
.set('maxEntrypointSize', 2500000)
.set('maxAssetSize', 2000000)
// drop console
config.optimization.minimizer('terser').tap((args) => {
args[0].terserOptions.compress.drop_console = true
return args
})
}
}
const setConfigureWebpack = config => {
if (isLib) {
const externalLibs = [
'vue',
'echarts',
'zrender'
]
// 将 vue 设置为外部依赖
let externals = [
function (context, request, callback) {
for (const lib of externalLibs) {
const reg = new RegExp(`^${lib}`)
if (reg.test(request)) {
return callback(null, lib)
}
}
callback()
}
]
config.externals = externals
config.output = {
...config.output,
library: 'VeCharts',
libraryExport: 'default'
}
}
}
module.exports = {
publicPath: './',
pages: {
index: {
entry: resolve('app/main.js')
}
},
lintOnSave: true,
productionSourceMap: false,
chainWebpack: config => setChainWebpack(config),
configureWebpack: config => setConfigureWebpack(config),
css: {
extract: false
},
devServer: {
port: 6066,
open: true,
overlay: {
warnings: true,
errors: true
}
}
}