Configuration
Storybook Rsbuild provides several ways to customize the build process and behavior. This guide covers the configuration options available in your .storybook/main.ts.
This guide focuses on Rsbuild-specific configurations. For general Storybook configuration (stories, addons, refs, etc.), please refer to the Storybook Configure documentation.
rsbuildFinal
The rsbuildFinal field gives you direct access to the Rsbuild configuration. You can use it to customize the build config, similar to webpackFinal in the Webpack builder.
This function receives the current Rsbuild config and an options object, and should return the modified config.
mergeRsbuildConfig for modifications
Always use mergeRsbuildConfig from @rsbuild/core to modify the config. Directly mutating properties like config.tools.rspack = {...} may not work because internal configs can be arrays of functions/objects, and direct assignment may be silently ignored.
Builder Options
You can configure the underlying Rsbuild builder through the core.builder options.
Inherited Rsbuild Configuration
The config selected by rsbuildConfigPath is automatically merged into the Storybook preview build. Production-only settings can affect or break the preview, so the following fields are not inherited:
source.entryoutput.distPath,output.filename,output.cleanDistPath,output.externals, andoutput.assetPrefixserver.publicDirdev.progressBar,dev.assetPrefix, anddev.writeToDisktools.htmlPlugintools.rspack.output.library,tools.rspack.output.globalObject, andtools.rspack.output.umdNamedDefine
This boundary also applies to configuration inherited by storybook-addon-rslib and storybook-addon-modernjs. Function-form tools.rspack values are opaque and cannot be stripped. Prefer a dedicated Rsbuild environment selected with environment to isolate Storybook-safe settings. To restore a stripped field intentionally, add it explicitly in Storybook's rsbuildFinal; explicit configuration runs after inherited configuration is stripped.
Plugins remain inherited because they commonly provide transforms required by the preview build. The Storybook CLI sets process.env.STORYBOOK to 'true' before loading project configuration, so use that condition to omit an app-only plugin that should not run in Storybook.
Option Reference
In development, the default { entries: false } compiles entry chunks eagerly while lazily compiling dynamically imported story modules. In production, this builder option is not applied, so lazy compilation remains off by default; lower-level Rsbuild or Rspack configuration can override that behavior. In development, automatic MSW detection also changes the default to false unless you explicitly configure this option. This differs from the Storybook webpack builder, where lazy compilation is opt-in and remains off unless enabled.
Webpack Addons Compatibility
Since Rspack is compatible with the webpack loader/plugin API, you can often use Storybook addons designed for Webpack. To do this, use the webpackAddons field instead of addons.
Framework Options
Framework-specific options allow you to tailor the behavior for React, Vue, etc.
React Options
For storybook-react-rsbuild, you can configure reactDocgen and legacy root API.
TypeScript Options
Storybook Rsbuild uses @rsbuild/plugin-type-check for type checking. You can configure it via the typescript field.
See Storybook TypeScript Docs for general TypeScript configuration.
Preview Output Layout
storybook build emits the preview with a flat layout — bundled JS and CSS land directly in the output directory (storybook-static by default), the same as the official webpack5 builder:
Versions before v3.4.0 nested these files under static/js/, static/js/async/, and static/css/.