Docs
Storybook Docs

swc

父级:main.js|ts 配置

¥Parent: main.js|ts configuration

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

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

通过基于受支持的 frameworks@storybook/addon-webpack5-compiler-swc 插件启用的基于 Webpack 的项目自定义 Storybook 的 SWC 设置,Angular、Create React App、Ember.js 和 Next.js 除外。

¥Customize Storybook's SWC setup for Webpack-based projects enabled via the @storybook/addon-webpack5-compiler-swc addon based on the supported frameworks, except Angular, Create React App, Ember.js and Next.js.

.storybook/main.ts
import type { Options } from '@swc/core';
// Replace your-framework with the webpack-based framework you are using (e.g., react-webpack5)
import type { StorybookConfig } from '@storybook/your-framework';
 
const config: StorybookConfig = {
  framework: {
    name: '@storybook/your-framework',
    options: {},
  },
  swc: (config: Options, options): Options => {
    return {
      ...config,
      // Apply your custom SWC configuration
    };
  },
};
 
export default config;

SWC.Options

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

¥The options provided by SWC are only applicable if you've enabled the @storybook/addon-webpack5-compiler-swc 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.