Skip to content

Commit caf4b61

Browse files
authored
docs: clarify swcReactOptions.refresh option (#4372)
1 parent 0e8026a commit caf4b61

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

website/docs/en/plugins/list/plugin-react.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ pluginReact({
108108
});
109109
```
110110

111+
### swcReactOptions.refresh
112+
113+
- **Type:** `boolean`
114+
- **Default:** based on [fastRefresh](#fastrefresh) and [dev.hmr](/config/dev/hmr)
115+
116+
Whether to enable [React Fast Refresh](https://www.npmjs.com/package/react-refresh).
117+
118+
Most of the time, you should use the plugin's [fastRefresh](#fastrefresh) option to enable or disable Fast Refresh.
119+
111120
### splitChunks
112121

113122
When [chunkSplit.strategy](/config/performance/chunk-split) set to `split-by-experience`, Rsbuild will automatically split `react` and `router` related packages into separate chunks by default:
@@ -225,7 +234,9 @@ pluginReact({
225234
- **Type:** `boolean`
226235
- **Default:** `true`
227236

228-
Whether to enable React [Fast Refresh](https://www.npmjs.com/package/react-refresh) in development mode.
237+
Whether to enable [React Fast Refresh](https://www.npmjs.com/package/react-refresh) in development mode.
238+
239+
If `fastRefresh` is set to `true`, `@rsbuild/plugin-react` will automatically register the [@rspack/plugin-react-refresh](https://www.npmjs.com/package/@rspack/plugin-react-refresh) plugin.
229240

230241
If you need to disable Fast Refresh, you can set it to `false`:
231242

website/docs/zh/plugins/list/plugin-react.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ pluginReact({
110110
});
111111
```
112112

113+
### swcReactOptions.refresh
114+
115+
- **类型:** `boolean`
116+
- **默认值:** 基于 [fastRefresh](#fastrefresh)[dev.hmr](/config/dev/hmr)
117+
118+
是否启用 [React Fast Refresh](https://www.npmjs.com/package/react-refresh)
119+
120+
大多数情况下,你应该使用插件的 [fastRefresh](#fastrefresh) 选项来启用或禁用 Fast Refresh。
121+
113122
### splitChunks
114123

115124
[chunkSplit.strategy](/config/performance/chunk-split) 设置为 `split-by-experience` 时,Rsbuild 默认会自动将 `react``router` 相关的包拆分为单独的 chunk:
@@ -227,7 +236,9 @@ pluginReact({
227236
- **类型:** `boolean`
228237
- **默认值:** `true`
229238

230-
是否在开发模式下启用 React [Fast Refresh](https://www.npmjs.com/package/react-refresh)
239+
是否在开发模式下启用 [React Fast Refresh](https://www.npmjs.com/package/react-refresh)
240+
241+
`fastRefresh` 设置为 `true` 时,`@rsbuild/plugin-react` 会自动注册 [@rspack/plugin-react-refresh](https://www.npmjs.com/package/@rspack/plugin-react-refresh) 插件。
231242

232243
如果你需要禁用 Fast Refresh,可以将其设置为 `false`
233244

0 commit comments

Comments
 (0)