Skip to content

Commit

Permalink
fix(rspack): add hook for dev server to log when compilation completed (
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 authored Sep 5, 2024
1 parent 95827a3 commit 8641d3f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/rspack/src/executors/dev-server/dev-server.impl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ExecutorContext,
logger,
parseTargetString,
readTargetOptions,
} from '@nx/devkit';
Expand Down Expand Up @@ -51,20 +52,29 @@ export default async function* runExecutor(
port: devServerConfig.port,
};

const baseUrl = `http://localhost:${options.port ?? 4200}`;

return yield* createAsyncIterable(({ next }) => {
const server = new RspackDevServer(
{
...devServerConfig,
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();
});
}

0 comments on commit 8641d3f

Please sign in to comment.