Skip to content

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

Merged
dominikg merged 7 commits into
mainfrom
feat/config-namespaced
Jul 13, 2022
Merged

refactor: move plugin options to "vitePlugin" in svelte.config.js#389
dominikg merged 7 commits into
mainfrom
feat/config-namespaced

Conversation

@dominikg

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@bluwy bluwy left a comment

Copy link
Copy Markdown
Member

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.

Comment thread docs/config.md Outdated
Comment thread docs/config.md Outdated
Comment thread packages/e2e-tests/configfile-custom/svelte.config.custom.cjs Outdated
Comment thread packages/e2e-tests/configfile-custom/svelte.config.custom.mjs Outdated
Comment thread .changeset/healthy-worms-double.md Outdated
@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
Copy Markdown

@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
Copy Markdown
Contributor Author

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

@ganigeorgiev

ganigeorgiev commented Jul 14, 2022

Copy link
Copy Markdown

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
Copy Markdown
Contributor 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
Copy Markdown

@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