Skip to content

Commit

Permalink
Properly stop esbuild process
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Kumpf committed Dec 13, 2021
1 parent 14123c2 commit e09c8c4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions assets/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ const build_opts = {
entryPoints: [path.join(__dirname, "..", "js", ENTRY_FILE)],
outfile: `${OUTPUT_DIR}/${OUTPUT_FILE}`,
minify: !isDevMode,
watch: isDevMode,
watch: isDevMode && {
onRebuild(error, result) {
if (error) console.error("[-] Esbuild failed:", error);
else console.log(`[+] Esbuild succeeded`);
},
},
bundle: true,
target: TARGET,
logLevel: "silent",
Expand All @@ -39,8 +44,13 @@ const build_opts = {
async function build() {
try {
console.log(`[+] Starting static assets build with esbuild (${MODE})...`);
await esbuild.build(build_opts);
result = await esbuild.build(build_opts);
console.log(`[+] Esbuild ${ENTRY_FILE} to ${OUTPUT_DIR} succeeded.`);

if (!!build_opts.watch) {
process.stdin.pipe(process.stdout);
process.stdin.on("end", () => result.stop());
}
} catch (e) {
console.error("[-] Error building:", e.message);
process.exit(1);
Expand Down

0 comments on commit e09c8c4

Please sign in to comment.