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-webpack5, vue3-vite)
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' }
这里很难记录其他选项。请查看类型定义以获取更多信息。