-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
26 lines (23 loc) · 793 Bytes
/
Copy pathbuild.ts
File metadata and controls
26 lines (23 loc) · 793 Bytes
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
import pc from "picocolors";
import { readFileSync } from "node:fs";
const { version } = JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf-8"));
const result = await Bun.build({
entrypoints: ["./index.ts"],
outdir: "./dist",
target: "bun",
sourcemap: "external",
minify: true,
define: {
VERSION: JSON.stringify(`${version}_bundled`),
},
});
if (result.success) {
console.log(`${pc.green("Build successful!")} Artifacts:`);
result.outputs.map(output => {
const readableSize = (output.size / 1024).toFixed(2) + " KiB";
console.log(` ${pc.blue(output.path)} ${pc.gray(readableSize)}`);
})
} else {
console.error("Build failed:");
console.error(result.logs.map(log => log.message).join("\n"));
}