-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.config.js
97 lines (94 loc) · 2.18 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
97
const path = require('path')
const TransformModulesPlugin = require('webpack-transform-modules-plugin')
const isDev = process.env.NODE_ENV === 'development'
function resolve(dir) {
return path.join(__dirname, dir)
}
const externals = {}
const cdn = {
dev: {
css: [
'//res.wx.qq.com/open/libs/weui/2.1.3/weui.css'
],
js: [
'//res.wx.qq.com/open/js/jweixin-1.4.0.js'
]
},
build: {
css: [
'//res.wx.qq.com/open/libs/weui/2.1.3/weui.min.css'
],
js: [
'//res.wx.qq.com/open/js/jweixin-1.4.0.js'
]
}
}
module.exports = {
publicPath: '/',
outputDir: 'dist',
devServer: {
port: 80,
host: 'wx.qyhever.com',
overlay: {
warnings: true,
errors: true
},
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
'/api': {
target: 'http://localhost:4444/',
changeOrigin: true,
pathRewrite: {
'^/api': '/'
}
}
}
},
pluginOptions: {
// import global scss variables and mixins
'style-resources-loader': {
preProcessor: 'scss',
patterns: [resolve('./src/assets/styles/global.scss')]
}
},
configureWebpack(config) {
config.externals = externals
if (process.env.NODE_ENV === 'production') {
// config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
}
},
chainWebpack(config) {
config.plugins.delete('prefetch')
config.plugins.delete('preload')
config.plugin('TransformModules').use(TransformModulesPlugin)
config.resolve.alias.set('cube-ui', 'cube-ui/lib')
// set svg-sprite-loader
config.module
.rule('svg')
.exclude.add(resolve('src/assets/icons'))
.end()
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(resolve('src/assets/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: '[name]'
})
config.plugin('html').tap(args => {
args[0].cdn = isDev ? cdn.dev : cdn.build
return args
})
},
css: {
loaderOptions: {
less: {
modifyVars: {
'@green': '#2483ff'
}
}
}
}
}