mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
Build file was still depending on frontend being included with the project, which it is not anymore
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
// Delete dist directory
|
|
import { $ } from "bun";
|
|
import { rawRoutes } from "~routes";
|
|
|
|
console.log(`Building at ${process.cwd()}`);
|
|
|
|
await $`rm -rf dist && mkdir dist`;
|
|
|
|
await Bun.build({
|
|
entrypoints: [
|
|
`${process.cwd()}/index.ts`,
|
|
`${process.cwd()}/cli.ts`,
|
|
// Force Bun to include endpoints
|
|
...Object.values(rawRoutes),
|
|
],
|
|
outdir: `${process.cwd()}/dist`,
|
|
target: "bun",
|
|
splitting: true,
|
|
minify: false,
|
|
external: ["bullmq", "frontend"],
|
|
}).then((output) => {
|
|
if (!output.success) {
|
|
console.log(output.logs);
|
|
}
|
|
});
|
|
|
|
// Fix for wrong Bun file resolution, replaces node_modules with ./node_modules inside all dynamic imports
|
|
// I apologize for this
|
|
await $`sed -i 's|import("node_modules/|import("./node_modules/|g' dist/*.js`;
|
|
|
|
// Copy Drizzle migrations to dist
|
|
await $`cp -r drizzle dist/drizzle`;
|
|
|
|
// Copy Sharp to dist
|
|
await $`mkdir -p dist/node_modules/@img`;
|
|
await $`cp -r node_modules/@img/sharp-libvips-linux-* dist/node_modules/@img`;
|
|
await $`cp -r node_modules/@img/sharp-linux-* dist/node_modules/@img`;
|
|
|
|
// Copy the Bee Movie script from pages
|
|
await $`cp beemovie.txt dist/beemovie.txt`;
|
|
|
|
console.log("Built!");
|