Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rspack): add hook for dev server to log when compilation completed #417

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
}
Loading