Skip to content

Commit bacc729

Browse files
authored
docs: add JSDoc for EnvironmentContext (#4725)
1 parent 4e0a8ae commit bacc729

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

packages/core/src/types/hooks.ts

+26
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,38 @@ export type ModifyEnvironmentConfigFn = (
165165

166166
export type EnvironmentContext = {
167167
index: number;
168+
/**
169+
* The unique name of the current environment is used to distinguish and locate the
170+
* environment, corresponds to the key in the `environments` configuration.
171+
*/
168172
name: string;
173+
/**
174+
* The entry object from the `source.entry` option.
175+
*/
169176
entry: RsbuildEntry;
177+
/**
178+
* The path information for all HTML assets.
179+
* This value is an object, the key is the entry name and the value is the relative
180+
* path of the HTML file in the dist directory.
181+
*/
170182
htmlPaths: Record<string, string>;
183+
/**
184+
* The absolute path of the output directory, corresponding to the `output.distPath.root`
185+
* config of Rsbuild.
186+
*/
171187
distPath: string;
188+
/**
189+
* The browserslist configuration of the current environment.
190+
*/
172191
browserslist: string[];
192+
/**
193+
* The absolute path of the tsconfig.json file, or `undefined` if the tsconfig.json file
194+
* does not exist in current project.
195+
*/
173196
tsconfigPath?: string;
197+
/**
198+
* The normalized Rsbuild config for the current environment.
199+
*/
174200
config: NormalizedEnvironmentConfig;
175201
};
176202

website/docs/en/api/javascript-api/environment-api.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ api.modifyRspackConfig((config, { environment }) => {
8787

8888
### distPath
8989

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

9292
- **Type:** `string`
9393

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

122122
The path information for all HTML assets.
123123

124-
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.
124+
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.
125125

126126
- **Type:**
127127

website/docs/zh/api/javascript-api/environment-api.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ api.modifyRspackConfig((config, { environment }) => {
8787

8888
### distPath
8989

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

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

123123
HTML 产物的路径信息。
124124

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

127127
- **类型:**
128128

0 commit comments

Comments
 (0)