Skip to content

Commit

Permalink
docs: improve explanation for env config (umijs#5381)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript authored Sep 9, 2020
1 parent a0d7a1e commit d16154e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
13 changes: 7 additions & 6 deletions docs/docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default {

## Configuration

We recommend configuring your app with `.umirc.ts`. It is possible to split your configurations into pieces and organize them in `config/config.ts` if your app requires complicated configuration. For example, if you need to configure routers, it would be a good choice to have it in an individual module alongside `config/config.ts`.
If your configurations are not complicated, we recommend configuring your app with `.umirc.ts`;
If your configurations are complicated, it is possible to split your configurations into pieces and organize them in `config/config.ts`. For example, if you need to configure routers, it would be a good choice to have it in an individual module called `config/routes.ts` alongside `config/config.ts`.

You have to choose between `.umirc.ts` and `config/config.ts`, `.umirc.ts` has higher priority.

Expand Down Expand Up @@ -44,10 +45,10 @@ Create `.umirc.local.ts`, it will be deep merged with `.umirc.ts` while using `u
For example:

```js
// .umirc.ts
// .umirc.ts or config/config.ts
export default { a: 1, b: 2 };

// .umirc.local.ts
// .umirc.local.ts or config/config.local.ts
export default { c: 'local' };
```

Expand All @@ -74,13 +75,13 @@ Environment variable `UMI_ENV` shall be used to identify configurations for diff
For example:

```js
// .umirc.js
// .umirc.js or config/config.js
export default { a: 1, b: 2 };

// .umirc.cloud.js
// .umirc.cloud.js or config/config.cloud.js
export default { b: 'cloud', c: 'cloud' };

// .umirc.local.js
// .umirc.local.js or config/config.local.js
export default { c: 'local' };
```

Expand Down
15 changes: 8 additions & 7 deletions docs/docs/config.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export default {

## 配置文件

推荐在 `.umirc.ts` 中写配置。如果配置比较复杂需要拆分,可以放到 `config/config.ts` 中,并把配置的一部分拆出去,比如路由。
如果项目的配置不复杂,推荐在 `.umirc.ts` 中写配置;
如果项目的配置比较复杂,可以将配置写在 `config/config.ts` 中,并把配置的一部分拆出去,比如路由配置可以拆成单独的 `config/routes.ts`

两者二选一`.umirc.ts` 优先级更高。
两种方式二选一`.umirc.ts` 优先级更高。

## TypeScript 提示

Expand All @@ -44,10 +45,10 @@ export default defineConfig({
比如,

```js
// .umirc.ts
// .umirc.ts 或者 config/config.ts
export default { a: 1, b: 2 };

// .umirc.local.ts
// .umirc.local.ts 或者 config/config.local.ts
export default { c: 'local' };
```

Expand All @@ -74,13 +75,13 @@ export default { c: 'local' };
举个例子,

```js
// .umirc.js
// .umirc.js 或者 config/config.js
export default { a: 1, b: 2 };

// .umirc.cloud.js
// .umirc.cloud.js 或者 config/config.cloud.js
export default { b: 'cloud', c: 'cloud' };

// .umirc.local.js
// .umirc.local.js 或者 config/config.local.js
export default { c: 'local' };
```

Expand Down

0 comments on commit d16154e

Please sign in to comment.