Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/nperez0111/bookhive. Track your books, share your shelves, see what others are reading bookhive.buzz
atproto bluesky books bookshelf goodreads management-system
Something went wrong. Try again.
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071/** * Build the server bundle. * * Steps: * 1. Build assets via Vite (CSS, JS, and manifest.json) * 2. Build server bundle via Bun (reads manifest.json at build time) * 3. Build pino OpenObserve transport separately for Docker runtime * * The manifest.json is generated by Vite and provides asset URLs * for production, eliminating runtime asset discovery. */import { spawn } from "bun";
// Build public assets first (CSS + JS via Vite)const assets = spawn({ cmd: ["bun", "run", "vite", "build"], cwd: process.cwd(), stdout: "inherit", stderr: "inherit",});if ((await assets.exited) !== 0) process.exit(1);
// Build server bundleconst mainResult = await Bun.build({ entrypoints: ["./src/index.ts"], outdir: "./dist", target: "bun", minify: { whitespace: true, identifiers: true, syntax: false, }, sourcemap: "none",});
if (!mainResult.success) { console.error("Build failed:"); for (const msg of mainResult.logs) { console.error(msg); } process.exit(1);}
// Build pino transport so it exists at dist/logger/open-observe.js for productionconst transportResult = await Bun.build({ entrypoints: ["./src/logger/open-observe.ts"], outdir: "./dist/logger", target: "bun", minify: { whitespace: true, identifiers: true, syntax: false, }, sourcemap: "none",});
if (!transportResult.success) { console.error("Transport build failed:"); for (const msg of transportResult.logs) { console.error(msg); } process.exit(1);}
for (const msg of [...mainResult.logs, ...transportResult.logs]) { if (msg.level === "warning") console.warn(msg.message);}
console.log("Server bundle written to dist/");console.log("Logger transport written to dist/logger/");