Skip to content

docs: clarify swcReactOptions.refresh option #4372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading