babel
父级: main.js|ts 配置
类型: (config: Babel.Config, options: Options) => Babel.Config | Promise<Babel.Config>
定制 Storybook 的 Babel 设置。
插件作者应该使用 babelDefault
,它在应用任何用户预设之前应用于预览配置。
.storybook/main.ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
import type { StorybookConfig } from '@storybook/your-framework';
const config: StorybookConfig = {
framework: '@storybook/your-framework',
stories: ['../src/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
async babel(config, { configType }) {
if (configType === 'DEVELOPMENT') {
// Your development configuration goes here
}
if (configType === 'PRODUCTION') {
// Your production configuration goes here.
}
return config;
},
};
export default config;
Babel.Config
Babel 提供的选项仅在你启用了 @storybook/addon-webpack5-compiler-babel
插件时适用。
如果你有现有的 Babel 配置文件(例如 .babelrc),Storybook 会自动检测并使用它,无需额外配置。
Options
类型: { configType?: 'DEVELOPMENT' | 'PRODUCTION' }
此处难以详细说明其他选项。请检查类型定义以获取更多信息。