Docs
Storybook Docs

babelDefault

父级:main.js|ts 配置

¥Parent: main.js|ts configuration

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

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

babelDefault 允许自定义 Storybook 的 Babel 设置。在应用任何用户预设之前,它会应用于预览配置,这使其对 插件作者 有用且值得推荐,以便终端用户的 babel 设置可以覆盖它。

¥babelDefault allows customization of Storybook's Babel setup. It is applied to the preview config before any user presets have been applied, which makes it useful and recommended for addon authors so that the end user's babel setup can override it.

要直接调整 Storybook 的 Babel 设置(而不是通过插件),请改用 babel

¥To adjust your Storybook's Babel setup directly—not via an addon—use babel instead.

import { TransformOptions } from '@babel/core';
 
export function babelDefault(config: TransformOptions) {
  return {
    plugins: [[require.resolve('@babel/plugin-transform-react-jsx'), {}, 'preset']],
  };
}

Babel.Config

Babel 提供的选项仅在你启用了 @storybook/addon-webpack5-compiler-babel 插件时才适用。

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

Options

类型:{ configType?: 'DEVELOPMENT' | 'PRODUCTION' }

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

还有其他难以在此处记录的选项。请自省类型定义以获取更多信息。

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