AFFiNE/packages/frontend/component/.storybook/main.ts

76 lines
2.0 KiB
TypeScript
Raw Normal View History

import { dirname, join } from 'path';
2023-12-04 11:32:19 +03:00
import { StorybookConfig } from '@storybook/react-vite';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import swc from 'unplugin-swc';
2023-12-04 11:32:19 +03:00
import { mergeConfig } from 'vite';
import { getRuntimeConfig } from '@affine/cli/src/webpack/runtime-config';
2023-12-04 11:32:19 +03:00
export default {
stories: ['../src/ui/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
2023-12-04 11:32:19 +03:00
addons: [
getAbsolutePath('@storybook/addon-links'),
getAbsolutePath('@storybook/addon-essentials'),
getAbsolutePath('@storybook/addon-interactions'),
getAbsolutePath('@storybook/addon-mdx-gfm'),
getAbsolutePath('storybook-dark-mode'),
'@chromatic-com/storybook',
2023-12-04 11:32:19 +03:00
],
2023-12-04 11:32:19 +03:00
framework: {
name: getAbsolutePath('@storybook/react-vite'),
2023-12-04 11:32:19 +03:00
options: {},
},
features: {},
docs: {},
2023-12-04 11:32:19 +03:00
async viteFinal(config, _options) {
return mergeConfig(config, {
plugins: [
vanillaExtractPlugin(),
swc.vite({
jsc: {
preserveAllComments: true,
parser: {
syntax: 'typescript',
dynamicImport: true,
tsx: true,
decorators: true,
},
target: 'es2022',
externalHelpers: false,
transform: {
react: {
runtime: 'automatic',
},
useDefineForClassFields: false,
decoratorVersion: '2022-03',
},
},
sourceMaps: true,
inlineSourcesContent: true,
}),
],
2023-12-04 11:32:19 +03:00
define: {
'process.env.CAPTCHA_SITE_KEY': `"${process.env.CAPTCHA_SITE_KEY}"`,
runtimeConfig: getRuntimeConfig({
distribution: 'browser',
mode: 'development',
channel: 'canary',
coverage: false,
}),
},
});
},
typescript: {
reactDocgen: 'react-docgen-typescript',
},
2023-12-04 11:32:19 +03:00
} satisfies StorybookConfig;
function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')));
}