Skip to content

Commit

Permalink
docs: add commands guide (#2062)
Browse files Browse the repository at this point in the history
* chore(create-dumi): add preview scripts

* docs: add commands doc

* Update docs/config/commands.md

Co-authored-by: Peach <[email protected]>

* chore: update

* chore: update category

---------

Co-authored-by: Peach <[email protected]>
  • Loading branch information
Wxh16144 and PeachScript authored Mar 30, 2024
1 parent 59c0f02 commit 6072519
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 1 deletion.
43 changes: 43 additions & 0 deletions docs/guide/commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
toc: content
group: 其他
order: 1
---

# 命令行

## `dumi dev`

启动本地开发服务器,进行项目的开发与调试。

## `dumi build`

构建 dumi 文档产物,适用于生产环境的部署。

## `dumi preview`

在本地启动一个静态 Web 服务器,将 docs-dist 文件夹运行在 http://127.0.0.1:4172, 用于预览构建后产物。

你可以通过 `--port` 参数来配置服务的运行端口。

```bash
dumi preview --port 9527
```

现在 `preview` 命令会将服务器运行在 http://127.0.0.1:9527

## `dumi setup`

初始化项目,会做临时文件的生成等操作。通常在 package.json 的 `scripts.prepare` 里设置。

```json
{
"scripts": {
"prepare": "dumi setup"
}
}
```

## `dumi version`

查看 dumi 版本,等同于 `dumi -v`
2 changes: 1 addition & 1 deletion docs/guide/faq.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
group: 其他
order: 2
order: 3
---

# 常见问题
Expand Down
1 change: 1 addition & 0 deletions docs/guide/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
group:
title: 其他
order: 3
order: 2
---

# 从 dumi 1.x 升级
Expand Down
3 changes: 3 additions & 0 deletions suites/boilerplate/templates/react/README.md.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ $ {{ npmClient }} run build:watch
# build docs
$ {{ npmClient }} run docs:build

# Locally preview the production build.
$ {{ npmClient }} run docs:preview

# check your project for potential problems
$ {{ npmClient }} run doctor
```
Expand Down
1 change: 1 addition & 0 deletions suites/boilerplate/templates/react/package.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"build": "father build",
"build:watch": "father dev",
"docs:build": "dumi build",
"docs:preview: "dumi preview",
"prepare": "husky install && dumi setup",
"doctor": "father doctor",
"lint": "npm run lint:es && npm run lint:css",
Expand Down
3 changes: 3 additions & 0 deletions suites/boilerplate/templates/site/README.md.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ $ {{ npmClient }} start

# build docs
$ {{ npmClient }} run build

# Locally preview the production build
$ {{ npmClient }} run preview
```

## LICENSE
Expand Down
1 change: 1 addition & 0 deletions suites/boilerplate/templates/site/package.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"start": "npm run dev",
"dev": "dumi dev",
"build": "dumi build",
"preview: "dumi preview",
"prepare": "husky install && dumi setup"
},
"authors": [{{#author}}
Expand Down

0 comments on commit 6072519

Please sign in to comment.