For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/guide/framework/vanilla.md.
close

Vanilla JS / TS

storybook-html-rsbuild 使用 Storybook 和 Rsbuild 构建纯 HTML、DOM 以及原生 JavaScript / TypeScript stories。完整示例可参考 Vanilla TypeScript sandbox。

环境要求

要求版本
Node.js>= 22.12.0
@rsbuild/core^2.0.0
storybook^11.0.0

与其他 frameworks 不同,storybook-html-rsbuild 不声明 typescript peer dependency,也不执行组件 docgen。如果启用了 typescript.check 进行类型检查,请参阅 typescript.checkOptions。

安装与配置

安装 storybook-html-rsbuild 和 @rsbuild/core:

npm
yarn
pnpm
bun
deno
npm install @rsbuild/core storybook-html-rsbuild -D

配置 .storybook/main.ts:

.storybook/main.ts
import type { 
import StorybookConfig
StorybookConfig
} from 'storybook-html-rsbuild'
const
const config: StorybookConfig
config
:
import StorybookConfig
StorybookConfig
= {
framework: string
framework
: 'storybook-html-rsbuild',
stories: string[]
stories
: ['../src/**/*.stories.@(js|mjs|ts)'],
} export default
const config: StorybookConfig
config

通用的 main.ts 配置和 CSF 用法请参阅 Storybook Configure 和 Writing Stories。

配置

在 .storybook/main.ts 中配置 framework.options:

builder

  • 类型: BuilderOptions
  • 默认值: {}

传递给 storybook-builder-rsbuild 的选项。请参阅 core.builder.options。