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

refactor: move plugin options to "vitePlugin" in svelte.config.js #389

Merged
merged 7 commits into from
Jul 13, 2022

Conversation

dominikg
Copy link
Member

To avoid problems with future name clashes we introduce vitePlugin namespace in svelte.config.js.

svelte options that are of global interest, eg compilerOptions, preprocess and extensions remain in the config root.

All other options mentioned in https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#plugin-options are moved.

Additional validation/errors have been introduced to avoid invalid options and inform the user.

@ghostdevv
Copy link
Member

Are you planning on supporting both for a while? there have been so many breaking changes in svelte projects recently it might be nice to have a break 😅

@dominikg
Copy link
Member Author

No, this is breaking. But it should be the last one before vite-plugin-svelte 1.0.0

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Some spacing nits, but the src looks good to me. Maybe we also want to export a new type for vitePlugin? Currently we have Options that's for passing the the plugin directly.

docs/config.md Outdated Show resolved Hide resolved
docs/config.md Outdated Show resolved Hide resolved
.changeset/healthy-worms-double.md Outdated Show resolved Hide resolved
@dominikg dominikg merged commit e8e52de into main Jul 13, 2022
@dominikg dominikg deleted the feat/config-namespaced branch July 13, 2022 06:53
@github-actions github-actions bot mentioned this pull request Jul 13, 2022
@ganigeorgiev
Copy link

@bluwy, @dominikg Is this change available in the recent v1.0.1 release?

When I wrap my options under vitePlugin as per the release note, like this:

// vite.config.js
export default defineConfig({
    plugins: [
        svelte({
            vitePlugin: {
                experimental: {
                    useVitePreprocess: true,
                },
            },
        }),
    ],
    ...
});

I'm seeing the following warning in the console:

[vite-plugin-svelte] invalid plugin options "vitePlugin" in inline config
{ vitePlugin: { experimental: { useVitePreprocess: true } } }

@dominikg
Copy link
Member Author

inline in vite config you do not wrap them. Only in svelte.config.js

@ganigeorgiev
Copy link

ganigeorgiev commented Jul 14, 2022

Ah, sorry. Yes, I've just read https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#experimental-options where is mentioned that this change is only for svelte.config.js.

This is kind of confusing to be honest and would be better to be consistent. Furthermore the example at the top of the page has this:

// vite.config.js
export default defineConfig({
  plugins: [
    svelte({
      configFile: false
      // your svelte config here
    })
  ]
});

where I thought because of // your svelte config here it should support the same props.

@dominikg
Copy link
Member Author

Imho vitePlugin would be redundant inside vite.config.js inline options. It is used in svelte.config.js because that file isn't exclusive for vite-plugin-svelte.
The inline options in vite.config.js on the other hand are ours to define and use.

@ganigeorgiev
Copy link

@dominikg Fair enough, I agree. It is just a little confusing and some people may stumble on this, but there is also validation for the config, so I think we are OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants