From fb1c696a27668591bf8492c323a37e7df3b2f41c Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Thu, 5 Sep 2024 15:12:03 +0100 Subject: [PATCH] fix(rspack): add hook for dev server to log when compilation completed --- .../src/executors/dev-server/dev-server.impl.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/rspack/src/executors/dev-server/dev-server.impl.ts b/packages/rspack/src/executors/dev-server/dev-server.impl.ts index 49ee9047a..2f1f1925b 100644 --- a/packages/rspack/src/executors/dev-server/dev-server.impl.ts +++ b/packages/rspack/src/executors/dev-server/dev-server.impl.ts @@ -1,5 +1,6 @@ import { ExecutorContext, + logger, parseTargetString, readTargetOptions, } from '@nx/devkit'; @@ -51,6 +52,8 @@ export default async function* runExecutor( port: devServerConfig.port, }; + const baseUrl = `http://localhost:${options.port ?? 4200}`; + return yield* createAsyncIterable(({ next }) => { const server = new RspackDevServer( { @@ -58,13 +61,20 @@ export default async function* runExecutor( onListening: () => { next({ success: true, - baseUrl: `http://localhost:${options.port ?? 4200}`, + baseUrl, }); }, }, compiler ); + server.compiler.hooks.done.tap('NX Rspack Dev Server', (stats) => { + if (stats.hasErrors()) { + logger.error(`NX Compilation failed. See above for more details.`); + } else { + logger.info(`NX Server ready at ${baseUrl}`); + } + }); server.start(); }); }