Docs
Storybook Docs

staticDirs

父级:main.js|ts 配置

¥Parent: main.js|ts configuration

类型:(string | { from: string; to: string })[]

¥Type: (string | { from: string; to: string })[]

设置 Storybook 加载的 静态文件 目录列表。

¥Sets a list of directories of static files to be loaded by Storybook.

.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)'],
  staticDirs: ['../public', '../static'],
};
 
export default config;

使用配置对象

¥With configuration objects

你还可以使用配置对象来定义目录:

¥You can also use a configuration object to define the directories:

.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)'],
  staticDirs: [{ from: '../my-custom-assets/images', to: '/assets' }],
};
 
export default config;