-
Notifications
You must be signed in to change notification settings - Fork 0
docs: complete dev command guide #53
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,43 @@ | ||
| # dev | ||
|
|
||
| TODO. | ||
| 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. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```bash | ||
| rs dev [options] | ||
| ``` | ||
|
|
||
| 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. | ||
|
|
||
| ## Options | ||
|
|
||
| `rs dev` supports the same development server options as Rsbuild. See the [Rsbuild CLI documentation](https://rsbuild.rs/guide/basic/cli#rsbuild) for details. | ||
|
|
||
| Examples: | ||
|
|
||
| ```bash | ||
| # Start the server and open the page in the browser | ||
| rs dev --open | ||
|
|
||
| # Use port 8080 and fail if it is already in use | ||
| rs dev --port 8080 --strict-port | ||
|
|
||
| # Make the server available on the local network | ||
| rs dev --host | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| See [`define.app()`](../configuration#define-app). | ||
| 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/): | ||
|
|
||
| ```ts title="rstack.config.ts" | ||
| import { define } from 'rstack'; | ||
|
|
||
| define.app({ | ||
| server: { | ||
| open: true, | ||
| port: 8080, | ||
| }, | ||
| }); | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,6 @@ | |
|
|
||
| TODO. | ||
|
|
||
| ## 配置 | ||
| ## 配置 \{#configuration} | ||
|
|
||
| 参见 [`define.app()`](../configuration#define-app)。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,43 @@ | ||
| # dev | ||
|
|
||
| TODO. | ||
| `rs dev` 命令用于启动应用的 [Rsbuild 开发服务器](https://rsbuild.rs/guide/basic/server)。它会以开发模式编译源码、监听文件变化,并按需进行模块热更新(HMR)或刷新页面。 | ||
|
|
||
| ## 配置 | ||
| ## 用法 \{#usage} | ||
|
|
||
| 参见 [`define.app()`](../configuration#define-app)。 | ||
| ```bash | ||
| rs dev [options] | ||
| ``` | ||
|
|
||
| 该命令会加载通过 [`define.app()`](../configuration#define-app) 注册的应用配置。当 Rstack 配置文件或其导入的任一依赖发生变化时,Rstack 会自动重启开发服务器并应用更新后的配置。 | ||
|
|
||
| ## 选项 \{#options} | ||
|
|
||
| `rs dev` 支持与 Rsbuild 相同的开发服务器选项,具体说明请参见 [Rsbuild CLI 文档](https://rsbuild.rs/zh/guide/basic/cli#rsbuild)。 | ||
|
|
||
| 示例: | ||
|
|
||
| ```bash | ||
| # 启动服务器并在浏览器中打开页面 | ||
| rs dev --open | ||
|
|
||
| # 使用 8080 端口,并在端口已被占用时退出 | ||
| rs dev --port 8080 --strict-port | ||
|
|
||
| # 允许通过局域网访问开发服务器 | ||
| rs dev --host | ||
| ``` | ||
|
|
||
| ## 配置 \{#configuration} | ||
|
|
||
| 在 [Rstack 配置文件](/guide/configuration#configuration-file)中通过 [`define.app()`](../configuration#define-app) 配置开发服务器。该 API 支持标准的 [Rsbuild 配置](https://rsbuild.rs/zh/config/): | ||
|
|
||
| ```ts title="rstack.config.ts" | ||
| import { define } from 'rstack'; | ||
|
|
||
| define.app({ | ||
| server: { | ||
| open: true, | ||
| port: 8080, | ||
| }, | ||
| }); | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,6 @@ | |
|
|
||
| TODO. | ||
|
|
||
| ## 配置 | ||
| ## 配置 \{#configuration} | ||
|
|
||
| 参见 [`define.doc()`](../configuration#define-doc)。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,6 @@ | |
|
|
||
| TODO. | ||
|
|
||
| ## 配置 | ||
| ## 配置 \{#configuration} | ||
|
|
||
| 参见 [`define.lib()`](../configuration#define-lib)。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,6 @@ | |
|
|
||
| TODO. | ||
|
|
||
| ## 配置 | ||
| ## 配置 \{#configuration} | ||
|
|
||
| 参见 [`define.lint()`](../configuration#define-lint)。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,6 @@ | |
|
|
||
| TODO. | ||
|
|
||
| ## 配置 | ||
| ## 配置 \{#configuration} | ||
|
|
||
| 参见 [`define.app()`](../configuration#define-app)。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,6 @@ | |
|
|
||
| TODO. | ||
|
|
||
| ## 配置 | ||
| ## 配置 \{#configuration} | ||
|
|
||
| 参见 [`define.staged()`](../configuration#define-staged)。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,6 @@ | |
|
|
||
| TODO. | ||
|
|
||
| ## 配置 | ||
| ## 配置 \{#configuration} | ||
|
|
||
| 参见 [`define.test()`](../configuration#define-test)。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.