build
类型: 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/addon-docs/blocks 模块,该模块使用 Docs Blocks 生成自动文档。
.storybook/main.ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
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-vite, nextjs, vue3-vite, etc.
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-a11y', '@storybook/addon-vitest'],
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-vite, nextjs, vue3-vite, etc.
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
阻止包含使用 autodocs 功能生成的自动文档。
.storybook/main.ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
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-vite, nextjs, vue3-vite, etc.
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-vite, nextjs, vue3-vite, etc.
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
禁用构建中的 tree shaking。
.storybook/main.ts
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc.
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;