Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit 8a4cfd2

Browse files
fix: shutdown dev server on fatal error (#143)
* Fix dev server restart error * chore: apply review changes Co-authored-by: Luke Edwards <[email protected]>
1 parent 9b2a107 commit 8a4cfd2

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

rollup.config.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ import { terser } from 'rollup-plugin-terser';
66

77
const production = !process.env.ROLLUP_WATCH;
88

9+
function serve() {
10+
let server;
11+
12+
function toExit() {
13+
if (server) server.kill(0);
14+
}
15+
16+
return {
17+
writeBundle() {
18+
if (server) return;
19+
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
20+
stdio: ['ignore', 'inherit', 'inherit'],
21+
shell: true
22+
});
23+
24+
process.on('SIGTERM', toExit);
25+
process.on('exit', toExit);
26+
}
27+
};
28+
}
29+
930
export default {
1031
input: 'src/main.js',
1132
output: {
@@ -52,20 +73,3 @@ export default {
5273
clearScreen: false
5374
}
5475
};
55-
56-
function serve() {
57-
let started = false;
58-
59-
return {
60-
writeBundle() {
61-
if (!started) {
62-
started = true;
63-
64-
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
65-
stdio: ['ignore', 'inherit', 'inherit'],
66-
shell: true
67-
});
68-
}
69-
}
70-
};
71-
}

0 commit comments

Comments
 (0)