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 in rsbuildFinal; returning a brand-new config is unsupported. Directly replacing properties like config.tools.rspack = {...} may also be silently ignored because internal configs can be arrays of functions and objects. Inside the function form of tools.rspack, modify and return the provided config or use the callback's mergeConfig utility; returning a brand-new object silently drops Storybook-injected wiring such as the sb.mock machinery.
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,dev.writeToDisk, anddev.clienttools.htmlPlugintools.rspack.output.library,tools.rspack.output.globalObject, andtools.rspack.output.umdNamedDefine
This boundary also applies to configuration inherited by storybook-addon-rslib, storybook-addon-rstack, 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
When environment is omitted, zero environments uses top-level config, one is selected automatically, and multiple environments require a name.
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 run an addon's webpackFinal, list it in webpackAddons. This is the only place where webpackFinal runs: the webpackFinal of entries in addons is not run, and neither is webpackFinal in .storybook/main.ts (use rsbuildFinal instead).
Each addon's webpackFinal runs on the fully composed Rspack config, after the builder's defaults and the webpack preset output, so it can read or replace existing rules, plugins, and resolve options. A tools.rspack hook added in rsbuildFinal still runs after it.
For webpackAddons entries, only webpackFinal is applied. Other preset hooks they export, such as managerEntries or previewAnnotations, are ignored. If an addon also provides UI or other hooks, list it in both addons and webpackAddons.
Framework Options
Framework-specific options allow you to tailor the behavior for React, Vue, etc.
React Options
For storybook-react-rsbuild, you can configure strictMode.
Vue Options
For storybook-vue3-rsbuild, framework.options.docgen selects the builder docgen engine for component props, events, slots, and exposes.
falsedisables builder docgen.'vue-docgen-api'(the default) or'vue-component-meta'picks the engine.{ plugin: 'vue-component-meta', tsconfig }passes a tsconfig path, resolved relative to the project root. It defaults to'tsconfig.json'; set it when your root tsconfig only contains references.
These options are ignored while server-side docgen is on, which is the default.
Web Components Options
For storybook-web-components-rsbuild, framework.options.customElementsManifest points at one or more Custom Elements Manifest files.
Paths resolve relative to the Storybook config directory. When the option is omitted, Storybook reads the customElements field from the nearest package.json. Tags that no manifest declares are generated from the project sources.
Component docgen
Storybook 11 extracts component metadata on the Storybook server (features.docgenServer). It is on by default for React, Vue, and Web Components. React, Vue, and Web Components need the typescript package installed; it is a required peer dependency of their frameworks. Vanilla HTML has no docgen.
For React, props come from TypeScript types. Default values are taken from inline destructuring defaults first, then Component.defaultProps / static defaultProps, then JSDoc @default / @defaultValue. propTypes is not read.
React's typescript.reactDocgen / typescript.reactDocgenTypescriptOptions and Vue's framework.options.docgen run only when features.docgenServer resolves to false. Leave the flag unset and React or Vue projects without typescript fall back to builder docgen automatically; set features.docgenServer: true explicitly and builder docgen is skipped even without typescript. Both options are deprecated and will be removed in Storybook 12.
To keep builder docgen for now:
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/.