-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
Copy pathpreset.ts
33 lines (24 loc) · 1020 Bytes
/
preset.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { dirname, join } from 'node:path';
import type { PresetProperty } from 'storybook/internal/types';
import { svelteDocgen } from './plugins/svelte-docgen';
import type { StorybookConfig } from './types';
import { handleSvelteKit } from './utils';
const getAbsolutePath = <I extends string>(input: I): I =>
dirname(require.resolve(join(input, 'package.json'))) as any;
export const core: PresetProperty<'core'> = {
builder: getAbsolutePath('@storybook/builder-vite'),
renderer: getAbsolutePath('@storybook/svelte'),
};
export const viteFinal: NonNullable<StorybookConfig['viteFinal']> = async (config, options) => {
const { plugins = [] } = config;
// TODO: set up eslint import to use typescript resolver
const { loadSvelteConfig } = await import('@sveltejs/vite-plugin-svelte');
const svelteConfig = await loadSvelteConfig();
// Add docgen plugin
plugins.push(await svelteDocgen(svelteConfig));
await handleSvelteKit(plugins, options);
return {
...config,
plugins,
};
};