Files
bun-app-template/scripts/dev.ts
2026-05-20 00:18:07 +08:00

27 lines
613 B
TypeScript

import { fileURLToPath } from "node:url";
const projectRoot = fileURLToPath(new URL("..", import.meta.url));
const apiServer = Bun.spawn(["bun", "--watch", "src/server/dev.ts", ...process.argv.slice(2)], {
cwd: projectRoot,
stderr: "inherit",
stdout: "inherit",
});
const viteServer = Bun.spawn(["bunx", "--bun", "vite", "--host"], {
cwd: projectRoot,
stderr: "inherit",
stdout: "inherit",
});
function shutdown() {
apiServer.kill();
viteServer.kill();
}
process.on("SIGINT", shutdown);
process.on("SIGTERM", shutdown);
await Promise.race([apiServer.exited, viteServer.exited]);
shutdown();