70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
/*
|
|
* SPDX-License-Identifier: GPL-3.0
|
|
* Modified for Aerocord, originally part of Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
|
* Copyright (c) 2024-2024 Aiek
|
|
* Copyright (c) 2024 RandomServer Community
|
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
|
*/
|
|
|
|
import { BuildOptions, build } from "esbuild";
|
|
|
|
const isDev = process.argv.includes("--dev");
|
|
|
|
const CommonOpts: BuildOptions = {
|
|
minify: true,
|
|
bundle: true,
|
|
sourcemap: "inline",
|
|
logLevel: "info"
|
|
};
|
|
|
|
const NodeCommonOpts: BuildOptions = {
|
|
...CommonOpts,
|
|
format: "cjs",
|
|
platform: "node",
|
|
external: ["electron"],
|
|
target: ["esnext"],
|
|
define: {
|
|
IS_DEV: JSON.stringify(isDev)
|
|
}
|
|
};
|
|
|
|
async function buildUnpacked() {
|
|
await Promise.all([
|
|
build({
|
|
...NodeCommonOpts,
|
|
entryPoints: ["src/main/index.ts"],
|
|
outfile: "dist/js/main.js",
|
|
footer: { js: "//# sourceURL=VCDMain" }
|
|
}),
|
|
build({
|
|
...NodeCommonOpts,
|
|
entryPoints: ["src/preload/index.ts"],
|
|
outfile: "dist/js/preload.js",
|
|
footer: { js: "//# sourceURL=VCDPreload" }
|
|
}),
|
|
build({
|
|
...NodeCommonOpts,
|
|
entryPoints: ["src/updater/preload.ts"],
|
|
outfile: "dist/js/updaterPreload.js",
|
|
footer: { js: "//# sourceURL=VCDUpdaterPreload" }
|
|
}),
|
|
build({
|
|
...CommonOpts,
|
|
globalName: "Vesktop",
|
|
entryPoints: ["src/renderer/index.ts"],
|
|
outfile: "dist/js/renderer.js",
|
|
format: "iife",
|
|
inject: ["./scripts/build/injectReact.mjs"],
|
|
jsxFactory: "VencordCreateElement",
|
|
jsxFragment: "VencordFragment",
|
|
external: ["@vencord/types/*"],
|
|
footer: { js: "//# sourceURL=VCDRenderer" }
|
|
})
|
|
]);
|
|
}
|
|
|
|
buildUnpacked().catch(err => {
|
|
console.error("Build failed:", err);
|
|
process.exit(1);
|
|
});
|