Skip to content

Commit fa99eb9

Browse files
committed
docs: complete dev command guide
1 parent 3ab3498 commit fa99eb9

12 files changed

Lines changed: 95 additions & 18 deletions

File tree

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ pnpm --filter rstack test
3131

3232
- Run `pnpm build` once before `pnpm test` command
3333

34+
## Documentation
35+
36+
- Keep corresponding content in `website/docs/en` and `website/docs/zh` aligned in structure, meaning, links, and examples.
37+
- Keep corresponding heading anchors identical between `website/docs/en` and `website/docs/zh`. When a translated heading would generate a different anchor, add an explicit anchor matching the English heading, for example `## 配置 \{#configuration}`.
38+
3439
## Project structure
3540

3641
```text

website/docs/en/guide/cli/dev.mdx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
11
# dev
22

3-
TODO.
3+
The `rs dev` command starts the [Rsbuild development server](https://rsbuild.rs/guide/basic/server) for an application. It compiles the source code in development mode, watches for changes, and applies hot module replacement (HMR) or reloads the page as needed.
4+
5+
## Usage
6+
7+
```bash
8+
rs dev [options]
9+
```
10+
11+
The command loads the application configuration registered with [`define.app()`](../configuration#define-app). When the Rstack configuration file or one of its imported dependencies changes, Rstack automatically restarts the development server and applies the updated configuration.
12+
13+
## Options
14+
15+
`rs dev` supports the same development server options as Rsbuild. See the [Rsbuild CLI documentation](https://rsbuild.rs/guide/basic/cli#rsbuild) for details.
16+
17+
Examples:
18+
19+
```bash
20+
# Start the server and open the page in the browser
21+
rs dev --open
22+
23+
# Use port 8080 and fail if it is already in use
24+
rs dev --port 8080 --strict-port
25+
26+
# Make the server available on the local network
27+
rs dev --host
28+
```
429

530
## Configuration
631

7-
See [`define.app()`](../configuration#define-app).
32+
Configure the development server through [`define.app()`](../configuration#define-app) in the [Rstack configuration file](/guide/configuration#configuration-file). It accepts the standard [Rsbuild configuration](https://rsbuild.rs/config/):
33+
34+
```ts title="rstack.config.ts"
35+
import { define } from 'rstack';
36+
37+
define.app({
38+
server: {
39+
open: true,
40+
port: 8080,
41+
},
42+
});
43+
```

website/docs/zh/guide/cli/build.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
TODO.
44

5-
## 配置
5+
## 配置 \{#configuration}
66

77
参见 [`define.app()`](../configuration#define-app)

website/docs/zh/guide/cli/dev.mdx

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
11
# dev
22

3-
TODO.
3+
`rs dev` 命令用于启动应用的 [Rsbuild 开发服务器](https://rsbuild.rs/guide/basic/server)。它会以开发模式编译源码、监听文件变化,并按需进行模块热更新(HMR)或刷新页面。
44

5-
## 配置
5+
## 用法 \{#usage}
66

7-
参见 [`define.app()`](../configuration#define-app)
7+
```bash
8+
rs dev [options]
9+
```
10+
11+
该命令会加载通过 [`define.app()`](../configuration#define-app) 注册的应用配置。当 Rstack 配置文件或其导入的任一依赖发生变化时,Rstack 会自动重启开发服务器并应用更新后的配置。
12+
13+
## 选项 \{#options}
14+
15+
`rs dev` 支持与 Rsbuild 相同的开发服务器选项,具体说明请参见 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild)
16+
17+
示例:
18+
19+
```bash
20+
# 启动服务器并在浏览器中打开页面
21+
rs dev --open
22+
23+
# 使用 8080 端口,并在端口已被占用时退出
24+
rs dev --port 8080 --strict-port
25+
26+
# 允许通过局域网访问开发服务器
27+
rs dev --host
28+
```
29+
30+
## 配置 \{#configuration}
31+
32+
[Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.app()`](../configuration#define-app) 配置开发服务器。该 API 支持标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/)
33+
34+
```ts title="rstack.config.ts"
35+
import { define } from 'rstack';
36+
37+
define.app({
38+
server: {
39+
open: true,
40+
port: 8080,
41+
},
42+
});
43+
```

website/docs/zh/guide/cli/doc.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
TODO.
44

5-
## 配置
5+
## 配置 \{#configuration}
66

77
参见 [`define.doc()`](../configuration#define-doc)

website/docs/zh/guide/cli/lib.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
TODO.
44

5-
## 配置
5+
## 配置 \{#configuration}
66

77
参见 [`define.lib()`](../configuration#define-lib)

website/docs/zh/guide/cli/lint.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
TODO.
44

5-
## 配置
5+
## 配置 \{#configuration}
66

77
参见 [`define.lint()`](../configuration#define-lint)

website/docs/zh/guide/cli/preview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
TODO.
44

5-
## 配置
5+
## 配置 \{#configuration}
66

77
参见 [`define.app()`](../configuration#define-app)

website/docs/zh/guide/cli/staged.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
TODO.
44

5-
## 配置
5+
## 配置 \{#configuration}
66

77
参见 [`define.staged()`](../configuration#define-staged)

website/docs/zh/guide/cli/test.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
TODO.
44

5-
## 配置
5+
## 配置 \{#configuration}
66

77
参见 [`define.test()`](../configuration#define-test)

0 commit comments

Comments
 (0)