文件
Storybook 文件

swc

Parent: main.js|ts 設定

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

自訂 Storybook 的 SWC 設定,適用於透過 @storybook/addon-webpack5-compiler-swc 附加元件啟用的基於 Webpack 的專案,並基於支援的框架,Angular、Create React App、Ember.js 和 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 附加元件時適用。

選項

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

還有其他選項難以在此處記錄。請檢視類型定義以獲取更多資訊。