webpackFinal
类型:async (config: Config, options: WebpackOptions) => Config
在使用webpack 构建器时,自定义 Storybook 的 Webpack 设置。
.storybook/main.ts
// Replace your-framework with the framework you are using, e.g. react-webpack5, nextjs, angular, 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)'],
webpackFinal: async (config, { configType }) => {
if (configType === 'DEVELOPMENT') {
// Modify config for development
}
if (configType === 'PRODUCTION') {
// Modify config for production
}
return config;
},
};
export default config;
选项
类型:{ configType?: 'DEVELOPMENT' | 'PRODUCTION' }
此处还有其他难以在此文档中说明的选项。请自行查看类型定义以获取更多信息。