The Preact plugin provides support for Preact, integrating features such as JSX compilation and React aliasing.
You can install the plugin using the following command:
npm add @rsbuild/plugin-preact -D
You can register the plugin in the rsbuild.config.ts
file:
import { pluginPreact } from '@rsbuild/plugin-preact';
export default {
plugins: [pluginPreact()],
};
After registering the plugin, you can directly develop Preact.
Whether to aliases react
, react-dom
to preact/compat
.
boolean
true
pluginPreact({
reactAliasesEnabled: false,
});
Whether to inject Prefresh for HMR.
boolean
true
>= v1.1.0
pluginPreact({
prefreshEnabled: false,
});
Include files to be processed by the @rspack/plugin-preact-refresh plugin. The value is the same as the rule.test
option in Rspack.
/\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/
>= v1.1.0
pluginPreact({
include: [/\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, /some-other-module/],
});
Exclude files from being processed by the @rspack/plugin-preact-refresh plugin. The value is the same as the rule.exclude
option in Rspack.
/[\\/]node_modules[\\/]/
>= v1.1.0
pluginPreact({
exclude: [/[\\/]node_modules[\\/]/, /some-other-module/],
});