Skip to content

Commit 8a2207b

Browse files
authored
feat: expose builder preview result for programming usage (#1944)
1 parent 7ef8647 commit 8a2207b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/core/src/node/serve.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mergeRsbuildConfig } from '@rsbuild/core';
1+
import { type RsbuildInstance, mergeRsbuildConfig } from '@rsbuild/core';
22
import type { UserConfig } from '@rspress/shared';
33
import { PluginDriver } from './PluginDriver';
44
import { initRsbuild } from './initRsbuild';
@@ -10,7 +10,9 @@ interface ServeOptions {
1010
}
1111

1212
// Serve ssg site in production
13-
export async function serve(options: ServeOptions) {
13+
export async function serve(
14+
options: ServeOptions,
15+
): Promise<ReturnType<RsbuildInstance['preview']>> {
1416
const { config, port: userPort, host: userHost } = options;
1517
const envPort = process.env.PORT;
1618
const envHost = process.env.HOST;
@@ -40,5 +42,5 @@ export async function serve(options: ServeOptions) {
4042
false,
4143
);
4244

43-
await builder.preview();
45+
return builder.preview();
4446
}

0 commit comments

Comments
 (0)