Docs
Storybook Docs

babel

Parent: main.js|ts configuration

Type: (config: Babel.Config, options: Options) => Babel.Config | Promise<Babel.Config>

Customize Storybook's Babel setup.

Addon authors should use babelDefault instead, which is applied to the preview config before any user presets have been applied.

.storybook/main.js
export default {
  // Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
  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;
  },
};

Babel.Config

The options provided by Babel are only applicable if you've enabled the @storybook/addon-webpack5-compiler-babel addon.

If you have an existing Babel configuration file (e.g., .babelrc), it will be automatically detected and used by Storybook without any additional configuration required.

Options

Type: { configType?: 'DEVELOPMENT' | 'PRODUCTION' }

There are other options that are difficult to document here. Please introspect the type definition for more information.