-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
96 lines (85 loc) · 2.13 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
85
86
87
88
89
90
91
92
93
94
95
96
const path = require('path')
const webpack = require('webpack')
const GitRevisionPlugin = require('git-revision-webpack-plugin')
const GitRevision = new GitRevisionPlugin()
const buildDate = JSON.stringify(new Date().toLocaleString())
const SkePlugin = require('./SkePlugin')
function resolve(dir) {
return path.join(__dirname, dir)
}
const isProd = process.env.NODE_ENV === 'production'
const assetsCDN = {
// webpack build externals
externals: {
vue: 'Vue'
},
css: [],
js: ['//cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js']
}
// vue.config.js
const vueConfig = {
configureWebpack: {
// webpack plugins
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin({
APP_VERSION: `"${require('./package.json').version}"`,
GIT_HASH: JSON.stringify(GitRevision.version()),
BUILD_DATE: buildDate
}),
new SkePlugin({
routes: ['/', '/about/index']
})
],
// if prod, add externals
externals: isProd ? assetsCDN.externals : {}
},
chainWebpack: config => {
config.resolve.alias.set('@$', resolve('src'))
config.plugin('html').tap(args => {
if (process.env.NODE_ENV === 'production') {
args[0].minify.removeComments = false
}
return args
})
const svgRule = config.module.rule('svg')
svgRule.uses.clear()
svgRule
.oneOf('inline')
.resourceQuery(/inline/)
.use('vue-svg-icon-loader')
.loader('vue-svg-icon-loader')
.end()
.end()
.oneOf('external')
.use('file-loader')
.loader('file-loader')
.options({
name: 'assets/[name].[hash:8].[ext]'
})
// if prod is on
// assets require on cdn
if (isProd) {
config.plugin('html').tap(args => {
args[0].cdn = assetsCDN
return args
})
}
},
css: {
loaderOptions: {
less: {
modifyVars: {},
javascriptEnabled: true
}
}
},
devServer: {
disableHostCheck: true,
port: 8000
},
productionSourceMap: false,
lintOnSave: undefined,
transpileDependencies: []
}
module.exports = vueConfig