The React plugin provides support for React features. The plugin internally integrates features such as React Refresh.
You can install the plugin using the following command:
You can register the plugin in the rsbuild.config.ts
file:
After registering the plugin, you can directly develop React.
The on-demand import capability of the React component library comes from source.transformImport.
When the Ant Design component library <= 4.x version is installed in the project, Rsbuild will automatically add on-demand import capabilities, and the default configuration is as follows:
When the Arco Design component library is installed in the project, Rsbuild will automatically add on-demand import capabilities, and the default configuration is as follows:
When you add configurations for antd
or @arco-design/web-react
in source.transformImport, the priority will be higher than the default configurations mentioned above.
At the same time, the above default behavior can be turned off by manually setting transformImport: false
.
When chunkSplit.strategy set to split-by-experience
, Rsbuild will automatically split react
and router
related packages into separate chunks by default:
lib-react.js
: includes react, react-dom, and react's sub-dependencies (scheduler).lib-router.js
: includes react-router, react-router-dom, and react-router's sub-dependencies (history, @remix-run/router).This option is used to control this behavior and determine whether the react
and router
related packages need to be split into separate chunks.