20 lines
409 B
JavaScript
20 lines
409 B
JavaScript
let server;
|
|
|
|
export function serve() {
|
|
function toExit() {
|
|
if (server) server.kill(0);
|
|
}
|
|
|
|
return {
|
|
writeBundle() {
|
|
if (server) return;
|
|
server = require("child_process").spawn("npm", ["run", "start", "--", "--dev"], {
|
|
stdio: ["ignore", "inherit", "inherit"],
|
|
shell: true,
|
|
});
|
|
|
|
process.on("SIGTERM", toExit);
|
|
process.on("exit", toExit);
|
|
},
|
|
};
|
|
}
|