feat: support reading Svelte config from vite.config.js/ts#3031
Merged
Conversation
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 detectedLatest 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 |
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>
Merged
This was referenced Jun 5, 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We're thinking about getting rid of
svelte.config.js(or rather, soft-deprecating it):vite.config.js/tsis 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.jswas 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.jsis read first / preferred if both exist, but if it does not exist or no options are retrieved through it thensvelte.config.js/tsis used.