-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.mjs
51 lines (45 loc) · 1.22 KB
/
build.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { execSync } from "child_process";
import { version } from "typescript"
import { buildSync } from "esbuild";
function hash() {
try {
return execSync("git rev-parse --short HEAD").toString().trim();
} catch (e) {
return "null";
}
}
try {
console.log("Building Music Bot...");
buildSync({
entryPoints: ["src/index.ts"],
bundle: true,
packages: "external",
platform: "node",
target: "node22",
format: "esm",
minify: true,
minifyIdentifiers: true,
minifySyntax: true,
minifyWhitespace: true,
mangleQuoted: true,
ignoreAnnotations: true,
treeShaking: true,
outfile: "dist/bundle.js",
define: {
__VERSION__: `"${hash()}"`,
__TYPESCRIPTVERSION__: `"${version}"`
},
});
console.log("Successfully built Music Bot!");
} catch (err) {
console.error(`Failed to build Music Bot:\n ${err}`);
process.exit(1);
}
if (process.argv.includes("--run")) {
console.log("Running Music Bot bundle...");
try {
execSync("node ./dist/bundle.js", { stdio: "inherit" });
} catch (_x) {
console.log("Music Bot closed.");
}
}