a
This commit is contained in:
		
							parent
							
								
									09bb6632f2
								
							
						
					
					
						commit
						ffb7047021
					
				| @ -6,14 +6,17 @@ | |||||||
|  * Copyright (c) 2023 Vendicated and Vencord contributors |  * Copyright (c) 2023 Vendicated and Vencord contributors | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| import { BuildOptions, build } from "esbuild"; | import { BuildContext, BuildOptions, context } from "esbuild"; | ||||||
|  | import { copyFile } from "fs/promises"; | ||||||
|  | 
 | ||||||
|  | import vencordDep from "./vencordDep.mjs"; | ||||||
| 
 | 
 | ||||||
| const isDev = process.argv.includes("--dev"); | const isDev = process.argv.includes("--dev"); | ||||||
| 
 | 
 | ||||||
| const CommonOpts: BuildOptions = { | const CommonOpts: BuildOptions = { | ||||||
|     minify: true, |     minify: !isDev, | ||||||
|     bundle: true, |     bundle: true, | ||||||
|     sourcemap: "inline", |     sourcemap: "linked", | ||||||
|     logLevel: "info" |     logLevel: "info" | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -28,27 +31,41 @@ const NodeCommonOpts: BuildOptions = { | |||||||
|     } |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| async function buildUnpacked() { | const contexts = [] as BuildContext[]; | ||||||
|     await Promise.all([ | async function createContext(options: BuildOptions) { | ||||||
|         build({ |     contexts.push(await context(options)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | async function copyVenmic() { | ||||||
|  |     if (process.platform !== "linux") return; | ||||||
|  | 
 | ||||||
|  |     return Promise.all([ | ||||||
|  |         copyFile( | ||||||
|  |             "./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-x64/node-napi-v7.node", | ||||||
|  |             "./static/dist/venmic-x64.node" | ||||||
|  |         ), | ||||||
|  |         copyFile( | ||||||
|  |             "./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-arm64/node-napi-v7.node", | ||||||
|  |             "./static/dist/venmic-arm64.node" | ||||||
|  |         ) | ||||||
|  |     ]).catch(() => console.warn("Failed to copy venmic. Building without venmic support")); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | await Promise.all([ | ||||||
|  |     copyVenmic(), | ||||||
|  |     createContext({ | ||||||
|         ...NodeCommonOpts, |         ...NodeCommonOpts, | ||||||
|         entryPoints: ["src/main/index.ts"], |         entryPoints: ["src/main/index.ts"], | ||||||
|         outfile: "dist/js/main.js", |         outfile: "dist/js/main.js", | ||||||
|         footer: { js: "//# sourceURL=VCDMain" } |         footer: { js: "//# sourceURL=VCDMain" } | ||||||
|     }), |     }), | ||||||
|         build({ |     createContext({ | ||||||
|         ...NodeCommonOpts, |         ...NodeCommonOpts, | ||||||
|         entryPoints: ["src/preload/index.ts"], |         entryPoints: ["src/preload/index.ts"], | ||||||
|         outfile: "dist/js/preload.js", |         outfile: "dist/js/preload.js", | ||||||
|         footer: { js: "//# sourceURL=VCDPreload" } |         footer: { js: "//# sourceURL=VCDPreload" } | ||||||
|     }), |     }), | ||||||
|         build({ |     createContext({ | ||||||
|             ...NodeCommonOpts, |  | ||||||
|             entryPoints: ["src/updater/preload.ts"], |  | ||||||
|             outfile: "dist/js/updaterPreload.js", |  | ||||||
|             footer: { js: "//# sourceURL=VCDUpdaterPreload" } |  | ||||||
|         }), |  | ||||||
|         build({ |  | ||||||
|         ...CommonOpts, |         ...CommonOpts, | ||||||
|         globalName: "Vesktop", |         globalName: "Vesktop", | ||||||
|         entryPoints: ["src/renderer/index.ts"], |         entryPoints: ["src/renderer/index.ts"], | ||||||
| @ -58,12 +75,20 @@ async function buildUnpacked() { | |||||||
|         jsxFactory: "VencordCreateElement", |         jsxFactory: "VencordCreateElement", | ||||||
|         jsxFragment: "VencordFragment", |         jsxFragment: "VencordFragment", | ||||||
|         external: ["@vencord/types/*"], |         external: ["@vencord/types/*"], | ||||||
|  |         plugins: [vencordDep], | ||||||
|         footer: { js: "//# sourceURL=VCDRenderer" } |         footer: { js: "//# sourceURL=VCDRenderer" } | ||||||
|     }) |     }) | ||||||
|     ]); | ]); | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| buildUnpacked().catch(err => { | const watch = process.argv.includes("--watch"); | ||||||
|     console.error("Build failed:", err); | 
 | ||||||
|     process.exit(1); | if (watch) { | ||||||
| }); |     await Promise.all(contexts.map(ctx => ctx.watch())); | ||||||
|  | } else { | ||||||
|  |     await Promise.all( | ||||||
|  |         contexts.map(async ctx => { | ||||||
|  |             await ctx.rebuild(); | ||||||
|  |             await ctx.dispose(); | ||||||
|  |         }) | ||||||
|  |     ); | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user