For AI agents: the complete documentation index is available at https://rspress.rs/zh/llms.txt, the full documentation bundle is available at https://rspress.rs/zh/llms-full.txt, and this page is available as Markdown at https://rspress.rs/zh/api/commands.md.
close

命令

通过本章节,你可以了解到 Rspress 内置的命令有哪些,以及如何使用这些命令。

对于 dev、build 和 preview 命令,可选的 [root] 参数用于指定文档根目录。省略时,Rspress 会优先使用配置文件中的 root;如果未配置 root,则使用当前目录下的 docs 目录。

rspress dev

rspress dev 命令用于启动一个本地开发服务器,提供一个文档进行预览和调试的开发环境。

Usage:
  $ rspress dev [root]

Options:
  --port <port>          设置服务监听的端口号
  --host [host]          设置服务监听的 host
  --base <base>          设置基础路径,并覆盖 config.base 配置
  -v, --version          显示版本号
  -h, --help             显示帮助信息
  -c, --config <config>  设置配置文件(相对路径或绝对路径)

rspress build

rspress build 命令用于构建出针对生产环境的文档产物。

Usage:
  $ rspress build [root]

Options:
  --base <base>          设置基础路径,并覆盖 config.base 配置
  -h, --help             显示帮助信息
  -c, --config <config>  设置配置文件(相对路径或绝对路径)

rspress preview

rspress preview 命令用于在本地预览 rspress build 命令构建出的产物。

Usage:
  $ rspress preview [root]

Options:
  --port <port>          设置服务监听的端口号
  --host [host]          设置服务监听的 host
  --base <base>          设置基础路径,并覆盖 config.base 配置
  -h, --help             显示帮助信息
  -c, --config <config>  设置配置文件(相对路径或绝对路径)

rspress eject

rspress eject 命令会将内置主题组件拷贝到你的项目中,便于自定义。

Usage:
  $ rspress eject [component]

Options:
  -h, --help             显示帮助信息
  -c, --config <config>  设置配置文件(相对路径或绝对路径)

其中 [component] 是可选参数,用于指定要导出的主题组件名;省略时,Rspress 会列出所有可导出的组件。

组件会被放置到 theme/components/<ComponentName> 目录下。请在 theme/index.tsx 中重新导出该组件以使用你的自定义版本。