aboutsummaryrefslogtreecommitdiff
path: root/scripts/build/build.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/build/build.mjs')
-rwxr-xr-xscripts/build/build.mjs53
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs
new file mode 100755
index 0000000..281246a
--- /dev/null
+++ b/scripts/build/build.mjs
@@ -0,0 +1,53 @@
+#!/usr/bin/node
+import esbuild from "esbuild";
+import { commonOpts, gitHashPlugin, globPlugins, makeAllPackagesExternalPlugin } from "./common.mjs";
+
+/**
+ * @type {esbuild.BuildOptions}
+ */
+const nodeCommonOpts = {
+ ...commonOpts,
+ format: "cjs",
+ platform: "node",
+ target: ["esnext"],
+ sourcemap: "linked",
+ plugins: [makeAllPackagesExternalPlugin],
+};
+
+await Promise.all([
+ esbuild.build({
+ ...nodeCommonOpts,
+ entryPoints: ["src/preload.ts"],
+ outfile: "dist/preload.js",
+ }),
+ esbuild.build({
+ ...nodeCommonOpts,
+ entryPoints: ["src/patcher.ts"],
+ outfile: "dist/patcher.js",
+ }),
+ esbuild.build({
+ ...commonOpts,
+ entryPoints: ["src/Vencord.ts"],
+ outfile: "dist/renderer.js",
+ format: "iife",
+ target: ["esnext"],
+ footer: { js: "//# sourceURL=VencordRenderer" },
+ globalName: "Vencord",
+ external: ["plugins", "git-hash"],
+ plugins: [
+ globPlugins,
+ gitHashPlugin
+ ],
+ sourcemap: "inline",
+ minify: true,
+ define: {
+ IS_WEB: "false"
+ }
+ }),
+]).catch(err => {
+ console.error("Build failed");
+ console.error(err.message);
+ // make ci fail
+ if (!watch)
+ process.exitCode = 1;
+});