Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions website/docs/en/api/javascript-api/environment-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Here you can find all the environment related APIs.

Environment context is a read-only object that provides some context information about the current environment.

In Rsbuild's [Plugin hooks](/plugins/dev/hooks#plugin-hooks), you can get the environment context object through the `environment` or `environments` parameter.
- **Type:**

```ts
type EnvironmentContext = {
Expand All @@ -23,6 +23,11 @@ type EnvironmentContext = {
};
```

You can get the environment context through the following ways:

1. In Rsbuild's [Plugin hooks](/plugins/dev/hooks#plugin-hooks), you can get the environment context object through the `environment` or `environments` parameter.
2. In the [Environment API](#environment-api-1), it is available via `environments.context`.

### name

The unique name of the current environment is used to distinguish and locate the environment, corresponds to the key in the [environments](/config/environments) configuration.
Expand Down Expand Up @@ -210,8 +215,7 @@ type EnvironmentAPI = {

You can get context information related to the current environment through the Environment API.

- **Type:** `EnvironmentContext`

- **Type:** [EnvironmentContext](#environment-context)
- **Example:**

```ts
Expand Down
12 changes: 8 additions & 4 deletions website/docs/zh/api/javascript-api/environment-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

## Environment context

Environment context 是一个只读对象,提供一些和当前环境有关的上下文信息
Environment context 是一个只读对象,提供一些和当前 environment 有关的上下文信息
Comment thread
chenjiahan marked this conversation as resolved.

在 Rsbuild 的 [Plugin hooks](/plugins/dev/hooks#plugin-hooks) 中,你可以通过 `environment` 或 `environments` 入参获取 environment context 对象。
- **类型:**

```ts
type EnvironmentContext = {
Expand All @@ -23,6 +23,11 @@ type EnvironmentContext = {
};
```

Environment context 可以通过以下方式获取:

1. 在 Rsbuild 的 [Plugin hooks](/plugins/dev/hooks#plugin-hooks) 中,你可以通过 `environment` 或 `environments` 入参获取 environment context 对象。
2. 在 [Environment API](#environment-api-1) 中,可以通过 `environments.context` 获取。

### name

当前环境的唯一名称,用于区分和定位环境,对应于 [environments](/config/environments) 配置中的 key。
Expand Down Expand Up @@ -211,8 +216,7 @@ type EnvironmentAPI = {

你可以通过 Environment API 获取和当前环境有关的上下文信息。

- **类型:** `EnvironmentContext`

- **类型:** [EnvironmentContext](#environment-context)
- **示例:**

```ts
Expand Down