构建
父级: main.js|ts 配置
类型: TestBuildConfig
提供配置选项以优化 Storybook 的生产构建输出。
test
类型: TestBuildFlags
{
disableBlocks?: boolean;
disabledAddons?: string[];
disableMDXEntries?: boolean;
disableAutoDocs?: boolean;
disableDocgen?: boolean;
disableSourcemaps?: boolean;
disableTreeShaking?: boolean;
}
通过从构建中禁用某些功能来配置 Storybook 的生产构建以进行性能测试。在运行 build-storybook
时,此功能通过设置 --test
标志 来启用。
此页面上记录的选项在 storybook build
命令中提供 --test
标志时会自动启用。我们建议您仅在需要为您的项目禁用特定功能或调试构建问题时才覆盖这些选项。
test.disableBlocks
类型: boolean
从构建中排除 @storybook/blocks
包,该包使用 文档块 生成自动文档。
.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)'],
build: {
test: {
disableBlocks: false,
},
},
};
export default config;
test.disabledAddons
类型: string[]
设置构建输出中将禁用的插件列表。
.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)'],
addons: ['@storybook/addon-essentials', '@storybook/addon-interactions', '@storybook/addon-a11y'],
build: {
test: {
disabledAddons: ['@storybook/addon-a11y'],
},
},
};
export default config;
test.disableMDXEntries
类型: boolean
启用此选项会从构建中删除 MDX 格式的用户编写的文档条目。
.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)'],
build: {
test: {
disableMDXEntries: false,
},
},
};
export default config;
test.disableAutoDocs
类型: boolean
阻止使用 自动文档 功能生成的自动文档包含在构建中。
.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)'],
build: {
test: {
disableAutoDocs: false,
},
},
};
export default config;
test.disableDocgen
类型: boolean
禁用自动 argType 和组件属性推断,以及任何基于您所用框架的受支持的静态分析工具。
.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)'],
build: {
test: {
disableDocgen: false,
},
},
};
export default config;
test.disableSourcemaps
类型: boolean
覆盖生成构建源映射的默认行为。
.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)'],
build: {
test: {
disableSourcemaps: false,
},
},
};
export default config;
test.disableTreeShaking
类型: boolean
在构建中禁用摇树优化。
.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)'],
build: {
test: {
disableTreeShaking: false,
},
},
};
export default config;