Files
planet/client/scripts/build-electron-main.mjs
T
linkong 842cba4dc7
ci / backend (push) Has been cancelled
ci / frontend (push) Has been cancelled
release / images (push) Has been cancelled
release / client_release (push) Has been cancelled
ci / delivery (push) Has been cancelled
release: bump version to 0.77.0
2026-11-20 16:59:38 +08:00

40 lines
1.0 KiB
JavaScript

import { rmSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const desktopRoot = join(__dirname, '..')
const outDir = join(desktopRoot, 'dist-electron')
rmSync(outDir, { recursive: true, force: true })
const mainBuild = await Bun.build({
entrypoints: [join(desktopRoot, 'src/main/index.ts')],
outdir: join(outDir, 'main'),
target: 'node',
format: 'cjs',
external: ['electron'],
minify: true,
naming: 'index.cjs',
})
if (!mainBuild.success) {
throw new AggregateError(mainBuild.logs, 'Electron main build failed')
}
const preloadBuild = await Bun.build({
entrypoints: [join(desktopRoot, 'src/preload/index.ts')],
outdir: join(outDir, 'preload'),
target: 'node',
format: 'cjs',
external: ['electron'],
minify: true,
naming: 'index.cjs',
})
if (!preloadBuild.success) {
throw new AggregateError(preloadBuild.logs, 'Electron preload build failed')
}
console.log('Built Electron main and preload to dist-electron/')