Skip to content

Commit 72a346c

Browse files
committed
chore: Write metafile
1 parent 77fcd86 commit 72a346c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

xmcl-electron-app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
cache
22
dist
3+
meta.json

xmcl-electron-app/build.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Configuration, build as electronBuilder } from 'electron-builder'
55
import { BuildOptions, build as esbuild } from 'esbuild'
66
import { createReadStream, createWriteStream, existsSync } from 'fs'
77
import { copy, ensureFile } from 'fs-extra'
8-
import { copyFile, readdir, rm, stat } from 'fs/promises'
8+
import { copyFile, readdir, rm, stat, writeFile } from 'fs/promises'
99
import path, { join, resolve } from 'path'
1010
import createPrintPlugin from 'plugins/esbuild.print.plugin'
1111
import { pipeline } from 'stream'
@@ -31,11 +31,15 @@ async function buildMain(options: BuildOptions, slient = false) {
3131
if (!slient) console.log(chalk.bold.underline('Build main process & preload'))
3232
const startTime = Date.now()
3333
if (!slient) options.plugins?.push(createPrintPlugin())
34-
await esbuild({
34+
const out = await esbuild({
3535
...options,
3636
outdir: resolve(__dirname, './dist'),
3737
entryPoints: [path.join(__dirname, './main/index.ts')],
3838
})
39+
40+
if (options.metafile) {
41+
await writeFile('./meta.json', JSON.stringify(out.metafile, null, 2))
42+
}
3943
const time = ((Date.now() - startTime) / 1000).toFixed(2)
4044
if (!slient) console.log(`Build completed in ${time}s.`)
4145
await copy(path.join(__dirname, '../xmcl-keystone-ui/dist'), path.join(__dirname, './dist/renderer'))
@@ -98,7 +102,7 @@ async function start() {
98102
})
99103
await rebuildProcess
100104
console.log(` ${chalk.blue('•')} rebuilt native modules ${chalk.blue('electron')}=${context.electronVersion} ${chalk.blue('arch')}=${context.arch}`)
101-
const time = await buildMain(esbuildConfig, true)
105+
const time = await buildMain({ ...esbuildConfig, metafile: true }, true)
102106
console.log(` ${chalk.blue('•')} compiled main process & preload in ${chalk.blue('time')}=${time}s`)
103107
},
104108
async afterPack(context) {

0 commit comments

Comments
 (0)