Skip to content
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

docs: add JSDoc for EnvironmentContext #4725

Merged
merged 1 commit into from
Mar 6, 2025
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
26 changes: 26 additions & 0 deletions packages/core/src/types/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,38 @@ export type ModifyEnvironmentConfigFn = (

export type EnvironmentContext = {
index: number;
/**
* The unique name of the current environment is used to distinguish and locate the
* environment, corresponds to the key in the `environments` configuration.
*/
name: string;
/**
* The entry object from the `source.entry` option.
*/
entry: RsbuildEntry;
/**
* The path information for all HTML assets.
* This value is an object, the key is the entry name and the value is the relative
* path of the HTML file in the dist directory.
*/
htmlPaths: Record<string, string>;
/**
* The absolute path of the output directory, corresponding to the `output.distPath.root`
* config of Rsbuild.
*/
distPath: string;
/**
* The browserslist configuration of the current environment.
*/
browserslist: string[];
/**
* The absolute path of the tsconfig.json file, or `undefined` if the tsconfig.json file
* does not exist in current project.
*/
tsconfigPath?: string;
/**
* The normalized Rsbuild config for the current environment.
*/
config: NormalizedEnvironmentConfig;
};

Expand Down
4 changes: 2 additions & 2 deletions website/docs/en/api/javascript-api/environment-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ api.modifyRspackConfig((config, { environment }) => {

### distPath

The absolute path of the output directory, corresponding to the [output.distPath.root](/config/output/dist-path) config in `RsbuildConfig`.
The absolute path of the output directory, corresponding to the [output.distPath.root](/config/output/dist-path) config of Rsbuild.

- **Type:** `string`

Expand Down Expand Up @@ -121,7 +121,7 @@ api.modifyRspackConfig((config, { environment }) => {

The path information for all HTML assets.

This API will return an object, the key is the entry name and the value is the relative path of the HTML file in the dist directory.
This value is an object, the key is the entry name and the value is the relative path of the HTML file in the dist directory.

- **Type:**

Expand Down
4 changes: 2 additions & 2 deletions website/docs/zh/api/javascript-api/environment-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ api.modifyRspackConfig((config, { environment }) => {

### distPath

构建产物输出目录的绝对路径,对应 RsbuildConfig 中的 [output.distPath.root](/config/output/dist-path) 配置项。
构建产物输出目录的绝对路径,对应 Rsbuild 的 [output.distPath.root](/config/output/dist-path) 配置项。

- **类型:** `string`
- **示例:**
Expand Down Expand Up @@ -122,7 +122,7 @@ api.modifyRspackConfig((config, { environment }) => {

HTML 产物的路径信息。

该 API 会返回一个对象,对象的 key 为 entry 名称,value 为 HTML 文件在产物目录下的相对路径。
这个值是一个对象,对象的 key 为 entry 名称,value 为 HTML 文件在产物目录下的相对路径。

- **类型:**

Expand Down
Loading