plugins
Registers Rsbuild plugins.
- Type:
- Default:
undefined
Please check out the Plugin List page to discover all available plugins.
Example
For example, to register the Sass plugin in Rsbuild:
- Installing the plugin:
- Registering the plugin:
Execution order
By default, plugins run in the order they appear in the plugins array. Built-in Rsbuild plugins always execute before user-defined plugins.
If a plugin specifies ordering controls such as the enforce property, the final execution sequence will be adjusted accordingly. See the enforce property for details.
Conditional registration
Falsy values in the plugins array are ignored, which lets you register plugins conditionally:
Async plugins
If the plugin is async, you can return a Promise object or use an async function, and Rsbuild will automatically wait for the Promise to be resolved:
Nested plugins
Rsbuild also supports nested plugins. You can pass an array that contains multiple plugins, similar to a plugin preset. This is useful for complex features that combine several plugins, such as framework integrations.
Local plugins
If your local code repository contains Rsbuild plugins, you can import them using relative paths.
Plugin options
If a plugin provides custom options, you can pass the configurations through the plugin function's parameters.
Plugin registration phase
Plugin registration only runs during the Rsbuild initialization phase. You cannot dynamically add other plugins within a plugin through the plugin API:
Rspack plugins
The plugins option is used to register Rsbuild plugins. If you need to register Rspack or webpack plugins, please use tools.rspack.
Unplugin
unplugin is a unified plugin system for various build tools. You can use plugins implemented based on unplugin in Rsbuild, just import the /rspack subpath of the plugin and register it via tools.rspack.
Here is an example of using unplugin-vue-components:
When you use the transform hook in unplugin, also use the transformInclude hook to target specific modules. If the transform hook matches an .html module, it replaces the default EJS transform from the html-rspack-plugin.
Please ensure that the version of
unpluginpackage is >= v1.6.0.

