This repository has been archived by the owner on Mar 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
vue.config.js
101 lines (100 loc) · 2.66 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
98
99
100
101
const path = require('path')
const resolve = dir => path.join(__dirname, dir)
module.exports = {
css: {
loaderOptions: {
less: {
javascriptEnabled: true
}
}
},
pages: getPages(),
assetsDir: 'common',
configureWebpack: config => {
},
pluginOptions: {
electronBuilder: {
builderOptions: {
files: [
{
'filter': ['**/*']
}
],
extraFiles: ['./extensions/'],
asar: false
},
chainWebpackRendererProcess: config => {
},
mainProcessFile: 'src/main/main.js',
mainProcessWatch: ['src/main'],
// [1.0.0-rc.4+] Provide a list of arguments that Electron will be launched with during "electron:serve",
// which can be accessed from the main process (src/background.js).
// Note that it is ignored when --debug flag is used with "electron:serve", as you must launch Electron yourself
mainProcessArgs: []
}
},
chainWebpack: config => {
config.resolve.alias
.set('app@', resolve('src/app'))
.set('_n', resolve('node_modules'))
.set('common@', resolve('src/common/'))
.set('communication@', resolve('src/communication/'))
.set('form@', resolve('src/form/'))
.set('client@', resolve('src/client/'))
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)))
},
// 打包时不生成.map文件,减少体积,加快速度
productionSourceMap: false,
// 跨域配置
devServer: {
// proxy: 'http://localhost:4000',
disableHostCheck: true
}
}
/**
* 全局 less 引入
* @param {*} rule 传递规则
*/
function addStyleResource (rule) {
rule.use('style-resource')
.loader('style-resources-loader')
.options({
patterns: [
path.resolve(__dirname, './src/common/theme/iview-variables.less')
]
})
}
/**
* 根据 MODE 选择对应的 pages 进行打包
*/
function getPages () {
return process.env.MODE === 'web'
? {
client: {
// entry for the page
entry: 'src/client/main.js',
// the source template
template: 'public/index.html',
// output as dist/index.html
filename: 'index.html'
}
}
: {
app: {
entry: 'src/app/main.js',
template: 'public/index.html',
filename: 'app.html'
},
communication: {
entry: 'src/communication/main.js',
template: 'public/index.html',
filename: 'communication.html'
},
forms: {
entry: 'src/forms/main.js',
template: 'public/index.html',
filename: 'forms.html'
}
}
}