-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
114 lines (114 loc) · 2.76 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
102
103
104
105
106
107
108
109
110
111
112
113
114
'use strict';
const projectConfig = require('./src/common/projectInfo.js').default; // 引入子系统运行打包配置
const projectName = projectConfig.projectName;
const menuCategory = 'Cloud';
const electronIcon = `public/${projectName}/icon/icon.`;
const path = require('path');
let isSplitProject = false; //是否是切割过后的项目
let _projectList = {};
try {
_projectList = require('./config/_projectList.json');
} catch (e) {
isSplitProject = true;
}
function resolve(dir) {
return path.join(__dirname, dir);
}
function createProjectConfig(config) {
let pages = {};
pages[config.projectName] = {
entry: `src/modules/${config.projectName}/main.js`,
template: 'public/index.html',
filename: 'index.html',
title: config.title || config.projectName,
chunks: ['chunk-vendors', 'chunk-common', config.projectName],
favicon: `public/${config.projectName}/favicon.ico`,
};
return { pages };
}
function getIgnoreFolder(ignore) {
if (_projectList !== 'index') {
for (let i in _projectList) {
if (i !== projectName) {
ignore.push('**/' + i + '/**');
}
}
}
return ignore;
}
module.exports = {
...createProjectConfig(projectConfig),
publicPath: './',
outputDir: 'build/web/' + (!isSplitProject ? projectName : ''),
assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false,
chainWebpack(config) {
if (!isSplitProject) {
config.plugin('copy').tap((arg) => {
arg[0][0].ignore = getIgnoreFolder(arg[0][0].ignore);
return [...arg];
});
}
config.resolve.alias.set('@', resolve('src'));
},
css: {
// 配置css模块
loaderOptions: {
// 向预处理器 Loader 传递配置选项
less: {
// 配置less(其他样式解析用法一致)
javascriptEnabled: true, // 设置为true
},
},
},
pluginOptions: {
'style-resources-loader': {
preProcessor: 'scss',
patterns: ['./src/assets/common/css/value.scss'],
},
electronBuilder: {
builderOptions: {
productName: projectName,
appId: projectConfig.appId,
directories: {
output: 'build/electron/' + (!isSplitProject ? projectName : ''),
},
win: {
icon: electronIcon + 'ico',
artifactName: '${productName}_setup_${version}.${ext}',
target: ['nsis'],
},
nsis: {
oneClick: false,
menuCategory: menuCategory,
shortcutName: projectConfig.logoText,
allowToChangeInstallationDirectory: true,
perMachine: true,
runAfterFinish: true,
},
dmg: {
contents: [
{
x: 410,
y: 150,
type: 'link',
path: '/Applications',
},
{
x: 130,
y: 150,
type: 'file',
},
],
},
mac: {
icon: electronIcon + `icns`,
},
linux: {
icon: electronIcon + `ico`,
},
},
},
},
};