diff options
author | Ven <vendicated@riseup.net> | 2022-10-23 23:23:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-23 23:23:52 +0200 |
commit | 5fac8be0ae68cbbdf3514973cbf925a31a765ef5 (patch) | |
tree | 8c184e0a2a9c8f4480e4c3880a58833e089a3da6 /scripts/build/build.mjs | |
parent | ffbb52512cd61764cfe04c1cf2707eb63d5e57bf (diff) | |
download | Vencord-5fac8be0ae68cbbdf3514973cbf925a31a765ef5.tar.gz Vencord-5fac8be0ae68cbbdf3514973cbf925a31a765ef5.tar.bz2 Vencord-5fac8be0ae68cbbdf3514973cbf925a31a765ef5.zip |
Vencord Standalone without git/node (#148)
Diffstat (limited to 'scripts/build/build.mjs')
-rwxr-xr-x | scripts/build/build.mjs | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index 163f4ce..bbf8105 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -18,7 +18,22 @@ */ import esbuild from "esbuild"; -import { commonOpts, fileIncludePlugin, gitHashPlugin, globPlugins, makeAllPackagesExternalPlugin } from "./common.mjs"; + +import { commonOpts, gitHash, globPlugins, isStandalone } from "./common.mjs"; + +const defines = { + IS_STANDALONE: isStandalone +}; +if (defines.IS_STANDALONE === "false") + // If this is a local build (not standalone), optimise + // for the specific platform we're on + defines["process.platform"] = JSON.stringify(process.platform); + +const header = ` +// Vencord ${gitHash} +// Standalone: ${defines.IS_STANDALONE} +// Platform: ${defines["process.platform"] || "Universal"} +`.trim(); /** * @type {esbuild.BuildOptions} @@ -30,8 +45,11 @@ const nodeCommonOpts = { target: ["esnext"], minify: true, bundle: true, - sourcemap: "linked", - external: ["electron"] + external: ["electron", ...commonOpts.external], + define: defines, + banner: { + js: header + } }; await Promise.all([ @@ -39,11 +57,15 @@ await Promise.all([ ...nodeCommonOpts, entryPoints: ["src/preload.ts"], outfile: "dist/preload.js", + footer: { js: "//# sourceURL=VencordPreload\n//# sourceMappingURL=vencord://preload.js.map" }, + sourcemap: "external", }), esbuild.build({ ...nodeCommonOpts, entryPoints: ["src/patcher.ts"], outfile: "dist/patcher.js", + footer: { js: "//# sourceURL=VencordPatcher\n//# sourceMappingURL=vencord://patcher.js.map" }, + sourcemap: "external", }), esbuild.build({ ...commonOpts, @@ -51,16 +73,16 @@ await Promise.all([ outfile: "dist/renderer.js", format: "iife", target: ["esnext"], - footer: { js: "//# sourceURL=VencordRenderer" }, + footer: { js: "//# sourceURL=VencordRenderer\n//# sourceMappingURL=vencord://renderer.js.map" }, globalName: "Vencord", - external: ["plugins", "git-hash"], + sourcemap: "external", plugins: [ globPlugins, - gitHashPlugin, - fileIncludePlugin + ...commonOpts.plugins ], define: { - IS_WEB: "false" + IS_WEB: "false", + IS_STANDALONE: isStandalone } }), ]).catch(err => { |