-
Notifications
You must be signed in to change notification settings - Fork 9
/
electron-builder.config.ts
95 lines (80 loc) · 1.77 KB
/
electron-builder.config.ts
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
import { execSync } from 'child_process'
import { type Configuration } from 'electron-builder'
import { once } from 'lodash'
import pkg from './package.json'
function defineConfig(config: Configuration) {
return config
}
const sh = (cmd: string) => {
console.log('[exec]: %s', cmd)
execSync(cmd, { stdio: 'inherit' })
}
// env
process.env.NODE_ENV = 'production'
// multiarch 会调用多次 build
const buildOnce = once(function build() {
if (process.env.SKIP_BUILD || process.argv.includes('--skip-build')) {
return
}
if (!(process.env.SKIP_BUILD_MAIN || process.argv.includes('--skip-build-main'))) {
console.log('[build main]')
sh('pnpm build:main')
}
if (!(process.env.SKIP_BUILD_UI || process.argv.includes('--skip-build-ui'))) {
console.log('[build ui]')
sh('pnpm build:ui')
}
})
export default defineConfig({
appId: pkg.bundleId,
productName: pkg.productName,
directories: {
// output: '',
},
files: [
{
from: 'bundle/${env.NODE_ENV}',
to: '.',
},
'./package.json',
],
extraResources: ['./assets/**'],
async beforeBuild() {
buildOnce()
},
async afterSign() {
console.log('[after sign]')
// process.nextTick(() => {
// const log = require('why-is-node-running').default
// log()
// })
},
artifactName: '${productName}-${version}-${os}-${arch}.${ext}',
mac: {
category: 'public.app-category.developer-tools',
publish: {
provider: 'github',
},
target: [
{
target: 'default',
arch: ['x64', 'arm64'],
},
],
},
dmg: {
iconSize: 160,
contents: [
{
x: 180,
y: 170,
},
{
x: 480,
y: 170,
type: 'link',
path: '/Applications',
},
],
},
})