export default function serve() { let server; function toExit() { if (server) server.kill(0); } return { writeBundle() { if (server) return; server = require("child_process").spawn( "npx", ["sirv", "dist", "--dev"], { stdio: ["ignore", "inherit", "inherit"], shell: true, } ); process.on("SIGTERM", toExit); process.on("exit", toExit); }, }; }