2022-10-12 23:13:59 +02:00
|
|
|
import vitePluginReact from '@vitejs/plugin-react';
|
2022-10-14 10:52:33 +02:00
|
|
|
import type { PluginOption } from 'vite';
|
2022-10-13 01:38:11 +02:00
|
|
|
import type { StorybookConfig } from '../../frameworks/react-vite/dist';
|
2022-10-12 23:13:59 +02:00
|
|
|
|
|
|
|
const config: StorybookConfig = {
|
|
|
|
stories: [
|
2022-10-17 11:20:51 +02:00
|
|
|
{
|
|
|
|
directory: '../manager/src/**/',
|
|
|
|
files: '*.stories.@(ts|tsx|js|jsx|mdx)',
|
|
|
|
titlePrefix: 'Manager',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
directory: '../components/src/**/',
|
2022-10-20 15:08:09 +02:00
|
|
|
files: 'tooltip/WithTooltip.stories.@(js|jsx|ts|tsx|mdx)',
|
|
|
|
titlePrefix: 'Components',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
directory: '../components/src/**/',
|
|
|
|
files: 'tooltip/TooltipLinkList.stories.@(js|jsx|ts|tsx|mdx)',
|
2022-10-17 11:20:51 +02:00
|
|
|
titlePrefix: 'Components',
|
|
|
|
},
|
|
|
|
// '../components/src/**/*.stories.@(js|jsx|ts|tsx|mdx)',
|
|
|
|
|
2022-10-12 23:13:59 +02:00
|
|
|
// '../../../addons/interactions/**/*.stories.@(ts|tsx|js|jsx|mdx)',
|
|
|
|
],
|
|
|
|
addons: [
|
|
|
|
'@storybook/addon-links',
|
|
|
|
'@storybook/addon-essentials',
|
|
|
|
'@storybook/addon-interactions',
|
|
|
|
],
|
|
|
|
framework: {
|
|
|
|
name: '@storybook/react-vite',
|
|
|
|
options: {},
|
|
|
|
},
|
2022-10-13 01:38:11 +02:00
|
|
|
viteFinal: (config) => {
|
|
|
|
return {
|
|
|
|
...config,
|
2022-10-14 10:52:33 +02:00
|
|
|
optimizeDeps: {
|
|
|
|
...config.optimizeDeps,
|
|
|
|
include: [
|
|
|
|
...(config.optimizeDeps?.include ?? []),
|
|
|
|
'react-element-to-jsx-string',
|
|
|
|
'core-js/modules/es.regexp.flags.js',
|
|
|
|
'react-colorful',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
/*
|
|
|
|
This might look complex but all we're doing is removing the default set of React Vite plugins
|
|
|
|
and adding them back in, but with the `jsxRuntime: 'classic'` option.
|
|
|
|
TODO: When we've upgraded to React 18 all of this shouldn't be necessary anymore
|
|
|
|
*/
|
2022-10-13 01:38:11 +02:00
|
|
|
plugins: [...withoutReactPlugins(config.plugins), vitePluginReact({ jsxRuntime: 'classic' })],
|
|
|
|
};
|
|
|
|
},
|
2022-10-12 23:13:59 +02:00
|
|
|
};
|
|
|
|
|
2022-10-13 01:38:11 +02:00
|
|
|
// recursively remove all plugins from the React Vite plugin
|
|
|
|
const withoutReactPlugins = (plugins: PluginOption[] = []) =>
|
|
|
|
plugins.map((plugin) => {
|
|
|
|
if (Array.isArray(plugin)) {
|
|
|
|
return withoutReactPlugins(plugin);
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
plugin &&
|
|
|
|
'name' in plugin &&
|
|
|
|
['vite:react-jsx', 'vite:react-babel', 'vite:react-refresh'].includes(plugin.name)
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return plugin;
|
|
|
|
});
|
|
|
|
|
2022-10-12 23:13:59 +02:00
|
|
|
export default config;
|