Storybook Rsbuild
repository·main·Indexed 41 days ago
https://github.com/rstackjs/storybook-rsbuildA high-performance builder for Storybook that leverages Rsbuild and Rspack to provide fast build and Hot Module Replacement (HMR) performance across various web frameworks. It includes specialized support for React Native Web via storybook-react-native-web-rsbuild and rsbuild-plugin-react-native-web, as well as an addon for Modern.js projects.
What's inside Storybook Rsbuild
Understand the project package structure
mainThe repository is organized into several functional areas:
packages/builder-rsbuild: The core Rsbuild builder package.packages/framework-*: Renderer packages (e.g.,html,react,react-native-web,vue3,web-components) containing runtime logic insrc/.packages/addon-*: Storybook addons (e.g.,modernjs,rslib,rstack).packages/rsbuild-plugin-react-native-web: A standalone Rsbuild plugin.sandboxes/: Runnable Storybook applications used for regression testing.tests/: A root-level cross-package integration test project.e2e/: Playwright end-to-end tests.website/: The public documentation site (built with Rspress).
Integrate Storybook with Figma
mainUse the Figma plugin to embed your live Storybook stories directly into Figma. This allows designers and developers to cross-reference design files with the actual live implementation in one place.Understand Modern.js integration limitations in Storybook
mainBecause
storybook-addon-modernjsworks as an addon rather than a full Storybook framework, it has specific limitations due to how Modern.js transforms configuration before passing it to Rsbuild.Supported
- Modern.js Configuration files
- Modern.js plugins that modify configuration
- Rsbuild plugins
Unsupported
- Webpack: Only Rspack is supported.
- SSR: Server-Side Rendering configuration will not work in Storybook.
- Runtime capabilities: Features like
<Link>navigation are unavailable. - Modern.js Plugin Hooks: Plugins will only successfully call the
configandresolveConfighooks; other lifecycle hooks may not function as expected.
Use Autodocs to generate component documentation
mainYou can use the Autodocs feature to automatically generate living, interactive reference documentation directly from your components and stories.Implement Module Federation in Storybook Rsbuild
mainStorybook Rsbuild supports Module Federation out of the box. You can implement two primary patterns:
- Host Application: Use the Modern.js Module Federation pattern to create a host application that loads federated modules from a remote, all running within Storybook.
- Federated Component Library: Use the Rslib Module Federation pattern to develop a federated component library using Rslib and Storybook.
Perform accessibility testing in Storybook
mainYou can automatically test your components for accessibility (a11y) issues during the development process to ensure compliance with accessibility standards.Theme the Storybook UI
mainYou can customize the visual appearance of the Storybook interface by applying themes to personalize it to your project's branding or user preference.Extend Storybook with Addons
mainIntegrate various tools into your Storybook workflow using Addons. Addons allow you to connect your existing development tools directly to the Storybook interface.Understand dependency bundling in packages/*
mainIn this monorepo, dependency classification in
packages/*determines whether a package is bundled or externalized:- Bundled:
devDependenciesare always bundled. - Externalized:
dependencies,optionalDependencies, andpeerDependenciesare externalized viacreateRslibConfig(which enablesoutput.autoExternal). - Vendoring: Some packages (e.g.,
slash,pretty-hrtimeinstorybook-builder-rsbuild) are intentionally placed indevDependenciesso they are vendored into the bundle rather than being externalized.
Warning: Do not reclassify dependencies from
devDependenciestodependencieswithout verifying the factory's external policy, as this changes the published output.- Bundled:
Test components with Storybook
mainUse your stories to perform testing on components across all their variations and complexities. This includes:
- General Testing: Testing components in all variations.
- Accessibility Testing: Automatically testing components for a11y (accessibility) issues during development.
Publish Storybook to Chromatic
mainUse Chromatic to publish your Storybook, enabling your team to review components and collaborate on UI changes.