Preact plugin
The Preact plugin provides support for Preact, integrating features such as JSX compilation and React aliasing.
Quick start
Install plugin
You can install the plugin using the following command:
Register plugin
You can register the plugin in the rsbuild.config.ts file:
rsbuild.config.ts
After registering the plugin, you can directly develop Preact.
Options
reactAliasesEnabled
Whether to aliases react, react-dom to preact/compat.
- Type:
boolean - Default:
true - Example: Disable aliases.
prefreshEnabled
Whether to inject Prefresh for HMR.
- Type:
boolean - Default:
true - Version:
>= v1.1.0 - Example: Disable Prefresh.
include
Include files to be processed by the @rspack/plugin-preact-refresh plugin. The value is the same as the rule.test option in Rspack.
- Type: RuleSetCondition
- Default:
/\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/ - Version:
>= v1.1.0
exclude
Exclude files from being processed by the @rspack/plugin-preact-refresh plugin. The value is the same as the rule.exclude option in Rspack.
- Type: RuleSetCondition
- Default:
/[\\/]node_modules[\\/]/ - Version:
>= v1.1.0

