Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove svelte-options from svelte-vite #20942

Merged
merged 4 commits into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions code/frameworks/svelte-vite/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ export const viteFinal: NonNullable<StorybookConfig['viteFinal']> = async (confi
// TODO: set up eslint import to use typescript resolver
// eslint-disable-next-line import/no-unresolved
const { svelte, loadSvelteConfig } = await import('@sveltejs/vite-plugin-svelte');
const svelteOptions: Record<string, any> = await options.presets.apply(
'svelteOptions',
{},
options
);
const svelteConfig = { ...(await loadSvelteConfig()), ...svelteOptions };
const svelteConfig = await loadSvelteConfig();

// Add svelte plugin if not present
// Add svelte plugin if the user does not have a Vite config of their own
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't exactly accurate for right now, though it hopefully will be sometime in the future, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You said above:

We don't actually create a file, but we do create a vite config, that we provide to the vite server when it starts up or when we build for production.

I was assuming that this in-memory Vite config would be created whether or not a vite.config.js is present. I suppose the old comment might be a bit more accurate in that it applies either way whether or not that file is present. But I think my comment better describes the use case we're trying to address and when we might encounter it, which is perhaps more useful for folks who are editing this code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I was being pedantic. They could have a vite config without the plugin, and we would add it. I'm just splitting hairs.

if (!(await hasVitePlugins(plugins, ['vite-plugin-svelte']))) {
plugins.push(svelte());
}
Expand Down