-
Notifications
You must be signed in to change notification settings - Fork 2
/
forge.config.js
133 lines (130 loc) · 3.17 KB
/
forge.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* electron-forge 打包配置
*
* @作者:rocyuan(袁鹏)
* @邮箱:[email protected]
* @微信:rocyuan666
*/
// const {
// utils: { fromBuildIdentifier },
// } = require('@electron-forge/core')
const os = require('os')
const { execSync } = require('child_process')
const { buildIcon, loadingGif, app } = require('./src/config')
// 系统类型
const osType = os.type()
// make配置
let makers = [
{
name: '@electron-forge/maker-zip',
},
]
if (osType == 'Windows_NT') {
makers.push(
{
name: '@electron-forge/maker-squirrel',
config: {
iconUrl: buildIcon.squirrel,
loadingGif,
setupIcon: buildIcon.win,
},
},
{
/**
* 构建msi安装包,电脑需要安装 wixtool 并配置环境变量
* 如:C:\Program Files (x86)\WiX Toolset v3.11\bin
* /wixtool/wix311.exe
*/
name: '@electron-forge/maker-wix',
config: {
icon: buildIcon.win,
},
}
)
} else if (osType == 'Darwin') {
makers.push({
name: '@electron-forge/maker-dmg',
config: {
icon: buildIcon.mac,
},
})
} else if (osType == 'Linux') {
/**
* 使用 lsb_release 判断系统类型,请先安装LSB
* dabian系: sudo apt-get install lsb-release
* RedHat系: sudo yum install redhat-lsb
*/
try {
const stdout = execSync('lsb_release -a')
if (stdout.indexOf('Ubuntu') != -1) {
makers.push({
/**
* 构建deb安装包,电脑需要安装 fakeroot 和 dpkg
* sudo apt install fakeroot dpkg
*/
name: '@electron-forge/maker-deb',
config: {
options: {
icon: buildIcon.linux,
},
},
})
} else if (stdout.indexOf('Centos') != -1) {
makers.push({
/**
* 构建rpm安装包,电脑需要安装 rpm 或 rpm-build
* sudo yum install rpm-build
* sudo apt install rpm
* sudo dnf install rpm-build
*/
name: '@electron-forge/maker-rpm',
config: {
icon: buildIcon.linux,
},
})
}
} catch (error) {
console.log('execSync错误', error)
}
}
module.exports = {
// buildIdentifier 配合 fromBuildIdentifier 使用
// buildIdentifier: 'production',
// https://electron.github.io/packager/main/interfaces/Options.html
packagerConfig: {
// appBundleId: fromBuildIdentifier({ production: 'top.rocyuan.app' }),
name: app.name,
appVersion: app.version,
appBundleId: app.bundleId,
appCopyright: app.copyright,
asar: true,
// 应用程序的图标(makers中配置的图标是安装程序的图标)
icon: buildIcon.iconNoExt,
ignore: [
'src',
'web',
'node_modules',
'build',
'wixtool',
'.vscode',
'.idea',
'.git',
'script',
'.eslintignore',
'.eslintrc.cjs',
'.gitignore',
'.npmrc',
'.prettierrc.json',
'forge.config.js',
'jsconfig.json',
'package-lock.json',
'LICENSE',
'README.md',
'vue',
],
},
// https://github.com/electron/rebuild#how-can-i-integrate-this-into-grunt--gulp--whatever
rebuildConfig: {},
makers,
plugins: [],
}