From 87070bcdf35a69447937d0cadef36e924484bcb1 Mon Sep 17 00:00:00 2001 From: Cole Lawrence Date: Mon, 13 Jun 2022 10:00:28 -0400 Subject: [PATCH] dev playground: Start dev server even if first build is error + remove redundant error logs --- packages/playground/devEnv/build.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/playground/devEnv/build.ts b/packages/playground/devEnv/build.ts index 880f63c..99cddb5 100644 --- a/packages/playground/devEnv/build.ts +++ b/packages/playground/devEnv/build.ts @@ -54,10 +54,14 @@ const liveReload = }, esbuildWatch: { onRebuild(error) { - // Notify clients on rebuild - openResponses.forEach((res) => res.write('data: update\n\n')) - openResponses.length = 0 - console.error(error ? error : 'Reloading...') + if (!error) { + console.error('Reloading...') + // Notify clients on rebuild + openResponses.forEach((res) => res.write('data: update\n\n')) + openResponses.length = 0 + } else { + console.error('Rebuild had errors...') + } }, }, } @@ -141,6 +145,10 @@ const config: BuildOptions = { esbuild .build(config) + .catch((err) => { + // if in dev mode, permit continuing to watch even if there was an error + return dev ? Promise.resolve() : Promise.reject(err) + }) .then(async () => { // Read index.html template const index = await readFile(path.join(__dirname, 'index.html'), 'utf8')