Skip to content

Commit aa64654

Browse files
committed
docs: add difference of modify config plugin hook
1 parent 26ab243 commit aa64654

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

website/docs/en/guide/faq/features.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ export default {
181181
};
182182
```
183183

184+
## Rsbuild plugin
185+
186+
### Why does using `modifyRsbuildConfig` to modify the configuration does not take effect?
187+
188+
Rslib internally generates Rsbuild's environments configurations, and each configuration item in the [lib](/config/lib) array corresponds to a specific environment configuration.
189+
190+
[modifyRsbuildConfig](https://rsbuild.rs/plugins/dev/hooks#modifyrsbuildconfig) is a global hook that cannot be effective for configurations under a specific environment. It is usually used in Rslib to modify globally effective plugins, etc. Therefore, you need to use [modifyEnvironmentConfig](https://rsbuild.rs/plugins/dev/hooks#modifyenvironmentconfig) instead to modify the configuration of a specific environment.
191+
192+
Refer to [Environment Plugin](https://rsbuild.rs/plugins/dev/#environment-plugin) to learn how to develop an Environment Plugin.
193+
184194
## Miscellaneous
185195

186196
### How to preserve module variables such as `__webpack_hash__` in the source code when generating outputs?

website/docs/zh/guide/faq/features.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ export default {
181181
};
182182
```
183183

184+
## Rsbuild 插件
185+
186+
### 为什么使用 `modifyRsbuildConfig` 修改配置不生效?
187+
188+
Rslib 会在内部生成 Rsbuild 的 environments 配置,每一个 [lib](/config/lib) 数组中的配置项对应一个特定 environment 配置。
189+
190+
[modifyRsbuildConfig](https://rsbuild.rs/zh/plugins/dev/hooks#modifyrsbuildconfig) 是一个全局 hook,无法对特定 environment 下的配置生效,在 Rslib 中通常用于修改全局生效的 plugins 等。因此需要使用 [modifyEnvironmentConfig](https://rsbuild.rs/zh/plugins/dev/hooks#modifyenvironmentconfig) 代替来修改特定 environment 的配置。
191+
192+
参考 [Environment 插件](https://rsbuild.rs/zh/plugins/dev/#environment-插件) 了解如何开发一个 Environment 插件。
193+
184194
## 其他
185195

186196
### 如何在生成产物时保留源码中的 `__webpack_hash__` 等模块变量?

0 commit comments

Comments
 (0)