Skip to content

Commit

Permalink
Merge pull request #20804 from storybookjs/fix-sveltekit
Browse files Browse the repository at this point in the history
Sveltekit: Ensure SSR is disabled
  • Loading branch information
JReinhold authored Jan 27, 2023
2 parents eb3cc8d + 6844457 commit 62ebc82
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
15 changes: 15 additions & 0 deletions code/frameworks/sveltekit/src/plugins/config-overrides.ts
Original file line number Diff line number Diff line change
@@ -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;
}
11 changes: 7 additions & 4 deletions code/frameworks/sveltekit/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> = {
Expand All @@ -16,10 +17,12 @@ export const viteFinal: NonNullable<StorybookConfig['viteFinal']> = 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 };
};

0 comments on commit 62ebc82

Please sign in to comment.