Skip to content

Commit

Permalink
docs: clarify swcReactOptions.refresh option (#4372)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Jan 15, 2025
1 parent 0e8026a commit caf4b61
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion website/docs/en/plugins/list/plugin-react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ pluginReact({
});
```

### swcReactOptions.refresh

- **Type:** `boolean`
- **Default:** based on [fastRefresh](#fastrefresh) and [dev.hmr](/config/dev/hmr)

Whether to enable [React Fast Refresh](https://www.npmjs.com/package/react-refresh).

Most of the time, you should use the plugin's [fastRefresh](#fastrefresh) option to enable or disable Fast Refresh.

### splitChunks

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:
Expand Down Expand Up @@ -225,7 +234,9 @@ pluginReact({
- **Type:** `boolean`
- **Default:** `true`

Whether to enable React [Fast Refresh](https://www.npmjs.com/package/react-refresh) in development mode.
Whether to enable [React Fast Refresh](https://www.npmjs.com/package/react-refresh) in development mode.

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.

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

Expand Down
13 changes: 12 additions & 1 deletion website/docs/zh/plugins/list/plugin-react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ pluginReact({
});
```

### swcReactOptions.refresh

- **类型:** `boolean`
- **默认值:** 基于 [fastRefresh](#fastrefresh)[dev.hmr](/config/dev/hmr)

是否启用 [React Fast Refresh](https://www.npmjs.com/package/react-refresh)

大多数情况下,你应该使用插件的 [fastRefresh](#fastrefresh) 选项来启用或禁用 Fast Refresh。

### splitChunks

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

是否在开发模式下启用 React [Fast Refresh](https://www.npmjs.com/package/react-refresh)
是否在开发模式下启用 [React Fast Refresh](https://www.npmjs.com/package/react-refresh)

`fastRefresh` 设置为 `true` 时,`@rsbuild/plugin-react` 会自动注册 [@rspack/plugin-react-refresh](https://www.npmjs.com/package/@rspack/plugin-react-refresh) 插件。

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

Expand Down

0 comments on commit caf4b61

Please sign in to comment.