Docs
Storybook Docs

build

父级:main.js|ts 配置

¥Parent: main.js|ts configuration

类型:TestBuildConfig

¥Type: TestBuildConfig

提供配置选项以优化 Storybook 的生产构建输出。

¥Provides configuration options to optimize Storybook's production build output.

test

类型:TestBuildFlags

¥Type: TestBuildFlags

{
  disableBlocks?: boolean;
  disabledAddons?: string[];
  disableMDXEntries?: boolean;
  disableAutoDocs?: boolean;
  disableDocgen?: boolean;
  disableSourcemaps?: boolean;
  disableTreeShaking?: boolean;
 
}

通过禁用构建中的某些功能,配置 Storybook 的生产构建以进行性能测试。运行 build-storybook 时,通过设置 --test flag 启用此功能。

¥Configures Storybook's production builds for performance testing purposes by disabling certain features from the build. When running build-storybook, this feature is enabled by setting the --test flag.

当向 storybook build 命令提供 --test 标志时,本页上记录的选项将自动启用。我们鼓励你仅在需要为项目禁用特定功能或调试构建问题时覆盖这些选项。

¥The options documented on this page are automatically enabled when the --test flag is provided to the storybook build command. We encourage you to override these options only if you need to disable a specific feature for your project or if you are debugging a build issue.

test.disableBlocks

类型:boolean

¥Type: boolean

从构建中排除 @storybook/blocks 包,该包使用 文档块 生成自动文档。

¥Excludes the @storybook/blocks package from the build, which generates automatic documentation with Docs 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[]

¥Type: string[]

设置将在构建输出中禁用的插件列表。

¥Sets the list of addons that will disabled in the build output.

.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-links',
    '@storybook/addon-essentials',
    '@storybook/addon-interactions',
    '@storybook/addon-a11y',
  ],
  build: {
    test: {
      disabledAddons: ['@storybook/addon-a11y'],
    },
  },
};
 
export default config;

test.disableMDXEntries

类型:boolean

¥Type: boolean

启用此选项将从构建中删除用户编写的 MDX 格式的文档条目。

¥Enabling this option removes user-written documentation entries in MDX format from the build.

.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

¥Type: boolean

防止使用 autodocs 功能生成的自动文档包含在构建中。

¥Prevents automatic documentation generated with the autodocs feature from being included in the build.

.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

¥Type: boolean

根据你使用的框架,使用任何受支持的静态分析工具禁用 自动 argType 和组件属性推断。

¥Disables automatic argType and component property inference with any of the supported static analysis tools based on the framework you are using.

.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

¥Type: boolean

覆盖为构建生成源映射的默认行为。

¥Overrides the default behavior of generating source maps for the build.

.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

¥Type: boolean

在构建中禁用 树摇动

¥Disables tree shaking in the build.

.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;