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

77 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'),
'@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({
2024-09-10 07:03:58 +03:00
distribution: 'web',
2023-12-04 11:32:19 +03:00
mode: 'development',
channel: 'canary',
2024-09-10 07:03:58 +03:00
static: false,
2023-12-04 11:32:19 +03:00
coverage: false,
static: false,
2023-12-04 11:32:19 +03:00
}),
},
});
},
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')));
}