diff --git a/code/frameworks/sveltekit/src/plugins/config-overrides.ts b/code/frameworks/sveltekit/src/plugins/config-overrides.ts new file mode 100644 index 000000000000..867083a82f28 --- /dev/null +++ b/code/frameworks/sveltekit/src/plugins/config-overrides.ts @@ -0,0 +1,15 @@ +import type { Plugin } from 'vite'; + +export function configOverrides() { + return { + name: 'storybook:sveltekit-overrides', + config: (conf) => { + // Some versions of sveltekit set ssr, we need it to be false + if (conf.build?.ssr) { + // eslint-disable-next-line no-param-reassign + conf.build.ssr = false; + } + return conf; + }, + } satisfies Plugin; +} diff --git a/code/frameworks/sveltekit/src/preset.ts b/code/frameworks/sveltekit/src/preset.ts index 42286e5a0785..9b0bf6091f70 100644 --- a/code/frameworks/sveltekit/src/preset.ts +++ b/code/frameworks/sveltekit/src/preset.ts @@ -2,6 +2,7 @@ import { viteFinal as svelteViteFinal } from '@storybook/svelte-vite/preset'; import type { PresetProperty } from '@storybook/types'; import { withoutVitePlugins } from '@storybook/builder-vite'; +import { configOverrides } from './plugins/config-overrides'; import { type StorybookConfig } from './types'; export const core: PresetProperty<'core', StorybookConfig> = { @@ -16,10 +17,12 @@ export const viteFinal: NonNullable = async (confi // Remove vite-plugin-svelte-kit from plugins if using SvelteKit // see https://github.com/storybookjs/storybook/issues/19280#issuecomment-1281204341 - plugins = await withoutVitePlugins(plugins, [ - // @sveltejs/kit@1.0.0-next.587 and later - 'vite-plugin-sveltekit-compile', - ]); + plugins = ( + await withoutVitePlugins(plugins, [ + // @sveltejs/kit@1.0.0-next.587 and later + 'vite-plugin-sveltekit-compile', + ]) + ).concat(configOverrides()); return { ...baseConfig, plugins }; };