2024-08-16 14:42:24 +03:00
|
|
|
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';
|
2024-08-16 14:42:24 +03:00
|
|
|
import swc from 'unplugin-swc';
|
2023-12-04 11:32:19 +03:00
|
|
|
import { mergeConfig } from 'vite';
|
2024-09-13 10:58:20 +03:00
|
|
|
import { getBuildConfig } from '@affine/cli/src/webpack/runtime-config';
|
2023-12-04 11:32:19 +03:00
|
|
|
|
|
|
|
export default {
|
2024-08-16 14:42:24 +03:00
|
|
|
stories: ['../src/ui/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
|
|
|
|
|
2023-12-04 11:32:19 +03:00
|
|
|
addons: [
|
2024-08-16 14:42:24 +03:00
|
|
|
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
|
|
|
],
|
2024-08-16 14:42:24 +03:00
|
|
|
|
2023-12-04 11:32:19 +03:00
|
|
|
framework: {
|
2024-08-16 14:42:24 +03:00
|
|
|
name: getAbsolutePath('@storybook/react-vite'),
|
2023-12-04 11:32:19 +03:00
|
|
|
options: {},
|
|
|
|
},
|
2024-08-16 14:42:24 +03:00
|
|
|
|
|
|
|
features: {},
|
|
|
|
|
|
|
|
docs: {},
|
|
|
|
|
2023-12-04 11:32:19 +03:00
|
|
|
async viteFinal(config, _options) {
|
|
|
|
return mergeConfig(config, {
|
2024-08-16 14:42:24 +03:00
|
|
|
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}"`,
|
2024-09-13 10:58:20 +03:00
|
|
|
runtimeConfig: getBuildConfig({
|
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,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
2024-08-16 14:42:24 +03:00
|
|
|
|
|
|
|
typescript: {
|
|
|
|
reactDocgen: 'react-docgen-typescript',
|
|
|
|
},
|
2023-12-04 11:32:19 +03:00
|
|
|
} satisfies StorybookConfig;
|
2024-08-16 14:42:24 +03:00
|
|
|
|
|
|
|
function getAbsolutePath(value: string): any {
|
|
|
|
return dirname(require.resolve(join(value, 'package.json')));
|
|
|
|
}
|