server/packages/api/build.ts

39 lines
1 KiB
TypeScript
Raw Normal View History

2025-05-01 16:27:34 +02:00
import { $, build } from "bun";
import manifest from "./package.json" with { type: "json" };
import { routes } from "./routes.ts";
2024-03-12 08:27:50 -10:00
2025-05-01 16:27:34 +02:00
console.log("Building...");
2023-12-08 16:56:00 -10:00
2024-04-09 01:14:53 -10:00
await $`rm -rf dist && mkdir dist`;
2023-12-08 16:59:02 -10:00
await build({
2024-04-06 19:30:49 -10:00
entrypoints: [
...Object.values(manifest.exports).map((entry) => entry.import),
2024-04-06 19:30:49 -10:00
// Force Bun to include endpoints
...Object.values(routes),
2024-04-06 19:30:49 -10:00
],
outdir: "dist",
2024-04-06 19:30:49 -10:00
target: "bun",
splitting: true,
minify: true,
external: [
...Object.keys(manifest.dependencies).filter((dep) =>
dep.startsWith("@versia"),
),
"@bull-board/ui",
// Excluded because Standard Schema imports those, but the code is never executed
"@valibot/to-json-schema",
"effect",
],
});
2025-05-01 16:27:34 +02:00
console.log("Copying files...");
await $`mkdir -p dist/node_modules`;
// Copy bull-board to dist
await $`mkdir -p dist/node_modules/@bull-board`;
await $`cp -rL ../../node_modules/@bull-board/ui dist/node_modules/@bull-board/ui`;
2025-05-01 16:27:34 +02:00
console.log("Build complete!");