Skip to content

Commit 859a6c5

Browse files
committed
fix: close compiler on SIGINT
1 parent 8378740 commit 859a6c5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/serve/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ class ServeCommand {
128128
return;
129129
}
130130

131+
process.on("SIGINT", () => {
132+
compiler.close();
133+
});
134+
131135
const servers = [];
132136

133137
if (cli.needWatchStdin(compiler) || devServerCLIOptions.stdin) {
@@ -153,7 +157,9 @@ class ServeCommand {
153157
});
154158
}),
155159
).then(() => {
156-
process.exit(0);
160+
compiler.close(() => {
161+
process.exit(0);
162+
});
157163
});
158164
});
159165
process.stdin.resume();

packages/webpack-cli/lib/webpack-cli.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2125,14 +2125,20 @@ class WebpackCLI {
21252125
return;
21262126
}
21272127

2128+
process.on("SIGINT", () => {
2129+
compiler.close();
2130+
});
2131+
21282132
const isWatch = (compiler) =>
21292133
compiler.compilers
21302134
? compiler.compilers.some((compiler) => compiler.options.watch)
21312135
: compiler.options.watch;
21322136

21332137
if (isWatch(compiler) && this.needWatchStdin(compiler)) {
21342138
process.stdin.on("end", () => {
2135-
process.exit(0);
2139+
compiler.close(() => {
2140+
process.exit(0);
2141+
});
21362142
});
21372143
process.stdin.resume();
21382144
}

0 commit comments

Comments
 (0)