功能
類型
{
argTypeTargetsV7?: boolean;
backgroundsStoryGlobals?: boolean;
legacyDecoratorFileOrder?: boolean;
viewportStoryGlobals?: boolean;
developmentModeForBuild?: boolean;
}
啟用 Storybook 的額外功能。
argTypeTargetsV7
(⚠️ 實驗性功能)
類型:boolean
從渲染函式篩選具有 "target" 類型的 args。
.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', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
features: {
argTypeTargetsV7: true,
},
};
export default config;
backgroundsStoryGlobals
類型:boolean
設定 Backgrounds 附加元件,選擇加入新的 story globals API 以設定背景。
.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', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
features: {
backgroundsStoryGlobals: true,
},
};
export default config;
legacyDecoratorFileOrder
類型:boolean
在附加元件或框架的 decorators 之前,先套用來自 preview.js 的 decorators。更多資訊。
.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', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
features: {
legacyDecoratorFileOrder: true,
},
};
export default config;
viewportStoryGlobals
類型:boolean
設定 Viewports 附加元件,選擇加入新的 story globals API 以設定 viewport。
.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', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
features: {
viewportStoryGlobals: true,
},
};
export default config;
developmentModeForBuild
類型:boolean
在建置的 Storybooks 中將 NODE_ENV
設定為 'development'
,以獲得更好的測試和偵錯功能。
.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', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
features: {
developmentModeForBuild: true,
},
};
export default config;