@@ -5,7 +5,7 @@ import { Configuration, build as electronBuilder } from 'electron-builder'
5
5
import { BuildOptions , build as esbuild } from 'esbuild'
6
6
import { createReadStream , createWriteStream , existsSync } from 'fs'
7
7
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'
9
9
import path , { join , resolve } from 'path'
10
10
import createPrintPlugin from 'plugins/esbuild.print.plugin'
11
11
import { pipeline } from 'stream'
@@ -31,11 +31,15 @@ async function buildMain(options: BuildOptions, slient = false) {
31
31
if ( ! slient ) console . log ( chalk . bold . underline ( 'Build main process & preload' ) )
32
32
const startTime = Date . now ( )
33
33
if ( ! slient ) options . plugins ?. push ( createPrintPlugin ( ) )
34
- await esbuild ( {
34
+ const out = await esbuild ( {
35
35
...options ,
36
36
outdir : resolve ( __dirname , './dist' ) ,
37
37
entryPoints : [ path . join ( __dirname , './main/index.ts' ) ] ,
38
38
} )
39
+
40
+ if ( options . metafile ) {
41
+ await writeFile ( './meta.json' , JSON . stringify ( out . metafile , null , 2 ) )
42
+ }
39
43
const time = ( ( Date . now ( ) - startTime ) / 1000 ) . toFixed ( 2 )
40
44
if ( ! slient ) console . log ( `Build completed in ${ time } s.` )
41
45
await copy ( path . join ( __dirname , '../xmcl-keystone-ui/dist' ) , path . join ( __dirname , './dist/renderer' ) )
@@ -98,7 +102,7 @@ async function start() {
98
102
} )
99
103
await rebuildProcess
100
104
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 )
102
106
console . log ( ` ${ chalk . blue ( '•' ) } compiled main process & preload in ${ chalk . blue ( 'time' ) } =${ time } s` )
103
107
} ,
104
108
async afterPack ( context ) {
0 commit comments