From b3be420587ecbdaec95f192c7eb248e252e4a7e6 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 13 Mar 2025 13:50:59 +0800 Subject: [PATCH] feat(CLI): allow to run without sub-command to trigger dev --- packages/core/src/cli/commands.ts | 3 ++- website/docs/en/guide/basic/cli.mdx | 6 ++++++ website/docs/zh/guide/basic/cli.mdx | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/core/src/cli/commands.ts b/packages/core/src/cli/commands.ts index 6bcbe15c67..3e931d621f 100644 --- a/packages/core/src/cli/commands.ts +++ b/packages/core/src/cli/commands.ts @@ -87,7 +87,8 @@ export function setupCommands(): void { // Apply common options to all commands applyCommonOptions(cli); - const devCommand = cli.command('dev', 'starting the dev server'); + // Allow to run `rsbuild` without any sub-command to trigger dev + const devCommand = cli.command('', 'starting the dev server').alias('dev'); const buildCommand = cli.command('build', 'build the app for production'); const previewCommand = cli.command( 'preview', diff --git a/website/docs/en/guide/basic/cli.mdx b/website/docs/en/guide/basic/cli.mdx index 1f058dd249..df9a7714c9 100644 --- a/website/docs/en/guide/basic/cli.mdx +++ b/website/docs/en/guide/basic/cli.mdx @@ -52,6 +52,12 @@ Options: --host specify the host that the Rsbuild server listens to ``` +You can also start the dev server by running `rsbuild` directly, which is equivalent to running `rsbuild dev`. + +```bash +npx rsbuild +``` + ### Opening page The `--open` option allows you to automatically open a page when starting the dev server, which is equivalent to setting [server.open](/config/server/open) to `true`. diff --git a/website/docs/zh/guide/basic/cli.mdx b/website/docs/zh/guide/basic/cli.mdx index b6bb20add4..7a6557ae22 100644 --- a/website/docs/zh/guide/basic/cli.mdx +++ b/website/docs/zh/guide/basic/cli.mdx @@ -52,6 +52,12 @@ Options: --host 指定 Rsbuild server 启动时监听的 host ``` +你也可以直接运行 `rsbuild` 来启动 dev server,等同于运行 `rsbuild dev`。 + +```bash +npx rsbuild +``` + ### 打开页面 通过 `--open` 选项可以在启动 dev server 时自动打开页面,等同于将 [server.open](/config/server/open) 设置为 `true`。