Skip to content

feat: support reading Svelte config from vite.config.js/ts#3031

Merged
dummdidumm merged 9 commits into
masterfrom
load-vite-config
Jun 3, 2026
Merged

feat: support reading Svelte config from vite.config.js/ts#3031
dummdidumm merged 9 commits into
masterfrom
load-vite-config

Conversation

@dummdidumm

@dummdidumm dummdidumm commented May 22, 2026

Copy link
Copy Markdown
Member

We're thinking about getting rid of svelte.config.js (or rather, soft-deprecating it): vite.config.js/ts is now pretty much the standard for new Svelte apps and generally a better place to put your config.

This is an important stepping stone towards that future. svelte.config.js was originally introduced for language-tools to read config options, now we can do the same by reading the Vite config.

With this PR, vite.config.js is read first / preferred if both exist, but if it does not exist or no options are retrieved through it then svelte.config.js/ts is used.

We're thinking about getting rid of `svelte.config.js` (or rather, soft-deprecating it): `vite.config.js/ts` is now pretty much the standard for new Svelte apps and generally a better place to put your config.

This is an important stepping stone towards that future. `svelte.config.js` was originally introduced for language-tools to read config options, now we can do the same by reading the Vite config.

With this PR, `svelte.config.js` is still read first / preferred if both exist, but if non exist but a `vite.config.js/ts` does, we can get the relevant options from it.
@changeset-bot

changeset-bot Bot commented May 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0907f4e

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dummdidumm

Copy link
Copy Markdown
Member Author

Pete brought up the good point that reading the Svelte config could be moved into its own pkg.

Rich-Harris added a commit to sveltejs/kit that referenced this pull request Jun 2, 2026
This allows you to pass the Svelte(Kit) config into the sveltekit Vite
plugin. Example:

```js
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import adapter from '@sveltejs/adapter-vercel';

export default defineConfig({
	plugins: [
		sveltekit({
			compilerOptions: {
				experimental: {
					async: true
				}
			},
			adapter: adapter(),
			experimental: {
				remoteFunctions: true,
				handleRenderingErrors: true
			}
		})
	],
});
```

Note how the `kit` namespace is at the same level as the other top level
entries; this is the only difference to the current `svelte.config.js`
layout.

If you set your options via the plugin, the `svelte.config.js` contents
are ignored, so it's either-or, not a merge.

In SvelteKit 3 we will likely make it a requirement to pass the options
via the Vite plugin instead - one less config file at the cluttered top
level of your project.

Fixes #5485

Because you can tell Vite which config to use this also fixes #13748

Related: sveltejs/language-tools#3031

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Rich Harris <rich.harris@vercel.com>
@dummdidumm dummdidumm marked this pull request as ready for review June 3, 2026 21:08
@dummdidumm dummdidumm merged commit 5b13da1 into master Jun 3, 2026
3 checks passed
@dummdidumm dummdidumm deleted the load-vite-config branch June 3, 2026 21:17
@github-actions github-actions Bot mentioned this pull request Jun 3, 2026
ghostdevv pushed a commit to ghostdevv/language-tools that referenced this pull request Jun 6, 2026
…3031)

We're thinking about getting rid of `svelte.config.js` (or rather, soft-deprecating it): `vite.config.js/ts` is now pretty much the standard for new Svelte apps and generally a better place to put your config.

This is an important stepping stone towards that future. `svelte.config.js` was originally introduced for language-tools to read config options, now we can do the same by reading the Vite config.

With this PR, `vite.config.js` is read first / preferred if both exist, but if it does not exist or no options are retrieved through it then `svelte.config.js/ts` is used.
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.

1 participant