Skip to content

Commit 00ae832

Browse files
authored
docs: correct rsbuild.addPlugins typing (#3817)
1 parent 5cde6d1 commit 00ae832

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

packages/core/src/types/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ export type PluginManager = {
128128
addPlugins: (
129129
plugins: Array<RsbuildPlugin | Falsy>,
130130
options?: {
131+
/**
132+
* Insert before the specified plugin.
133+
*/
131134
before?: string;
132135
/**
133136
* Add a plugin for the specified environment.
134-
*
135137
* If environment is not specified, it will be registered as a global plugin (effective in all environments)
136138
*/
137139
environment?: string;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ This method needs to be called before compiling. If it is called after compiling
528528
- **Type:**
529529

530530
```ts
531-
type AddPluginsOptions = { before?: string } | { after?: string };
531+
type AddPluginsOptions = { before?: string; environment?: string };
532532

533533
function AddPlugins(
534534
plugins: Array<RsbuildPlugin | Falsy>,
@@ -544,8 +544,8 @@ rsbuild.addPlugins([pluginFoo(), pluginBar()]);
544544
// Insert before the bar plugin
545545
rsbuild.addPlugins([pluginFoo()], { before: 'bar' });
546546

547-
// Insert after the bar plugin
548-
rsbuild.addPlugins([pluginFoo()], { after: 'bar' });
547+
// Add plugin for node environment
548+
rsbuild.addPlugins([pluginFoo()], { environment: 'node' });
549549
```
550550

551551
## rsbuild.getPlugins

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ const compiler = await rsbuild.createCompiler();
549549
- **类型:**
550550

551551
```ts
552-
type AddPluginsOptions = { before?: string } | { after?: string };
552+
type AddPluginsOptions = { before?: string; environment?: string };
553553

554554
function AddPlugins(
555555
plugins: Array<RsbuildPlugin | Falsy>,
@@ -565,8 +565,8 @@ rsbuild.addPlugins([pluginFoo(), pluginBar()]);
565565
// 在 bar 插件之前插入
566566
rsbuild.addPlugins([pluginFoo()], { before: 'bar' });
567567

568-
// 在 bar 插件之后插入
569-
rsbuild.addPlugins([pluginFoo()], { after: 'bar' });
568+
// 为 node 环境添加插件
569+
rsbuild.addPlugins([pluginFoo()], { environment: 'node' });
570570
```
571571

572572
## rsbuild.getPlugins

0 commit comments

Comments
 (0)