/** * 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 bundle const 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 production const 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/");