Skip to content

feat(create): provide svelte config in vite.config.js during create#1119

Merged
jycouet merged 16 commits into
mainfrom
feat/provide-svelte-config-in-vite-config-during-create
Jun 8, 2026
Merged

feat(create): provide svelte config in vite.config.js during create#1119
jycouet merged 16 commits into
mainfrom
feat/provide-svelte-config-in-vite-config-during-create

Conversation

@manuel3108

@manuel3108 manuel3108 commented Jun 5, 2026

Copy link
Copy Markdown
Member

Relates #1111
Discards: #1117
(let's try and create multiple small prs)

Description

I absolutely do not understand why we had so many svelte.config.js's flying around, especially since they were all close to identical. Therefore removed most of them. Since everything in the vite.config is js based, there is no need to bother about .ts extensions during create.


JYC update:

  • even if vite.config.ts has no typescript today, when I select ts, I expect to have it in ts (and it's today's behavior). Let's keep it here.
  • added a util for svelteConfig & updated all addons

Todos:

  • playground test reading vite config, needs @sveltejs/load-config
  • snapshots
  • changeset

Sources:

Checklist

  • Update snapshots (if applicable)
  • Add a changeset (if applicable)
  • Allow maintainers to edit this PR
  • I care about what I'm doing, no matter the tool I use (Notepad, Sublime, VSCode, AI...)

@changeset-bot

changeset-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c5aa89e

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

This PR includes changesets to release 2 packages
Name Type
sv Minor
@sveltejs/sv-utils Minor

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

jycouet added 9 commits June 6, 2026 09:26
Reads/edits config wherever it lives - a svelte.config.{js,ts} default export or the object passed to sveltekit() in vite.config.{js,ts}.
parseKitOptions now locates the config in either place and falls back to defaults instead of throwing. Deprecates file.svelteConfig in favour of the svelteConfig helper.
mdsvex, drizzle, sveltekit-adapter and eslint now edit the config wherever it lives; eslint only wires svelteConfig when a standalone svelte.config file exists.
…s/kit ^2.62.0

The inlined vite.config config needs kit >= 2.62.0; snapshots regenerated.
@jycouet jycouet closed this Jun 8, 2026
@jycouet jycouet reopened this Jun 8, 2026
@svelte-docs-bot

Copy link
Copy Markdown

@jycouet jycouet marked this pull request as ready for review June 8, 2026 13:52
Comment thread documentation/docs/50-api/20-sv-utils.md Outdated
Comment thread documentation/docs/50-api/20-sv-utils.md Outdated
Comment thread packages/sv-utils/src/svelte-config.ts Outdated
Comment thread packages/sv/src/cli/tests/snapshots/create-with-all-addons/e2e/demo.test.ts Outdated
@manuel3108

manuel3108 commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

Ran some local tests, and everything is working perfectly fine, as soon as those (optional) comments are adressed, im fine by you merging this!

Also lets keep it minor as you suggested.

Can't approve since im the author

@jycouet jycouet merged commit 20f6cf7 into main Jun 8, 2026
6 checks passed
@jycouet jycouet deleted the feat/provide-svelte-config-in-vite-config-during-create branch June 8, 2026 18:22
@github-actions github-actions Bot mentioned this pull request Jun 8, 2026
@hyunbinseo

Copy link
Copy Markdown
Contributor

Does eslint.config.js file no longer need svelteConfig imported from svelte.config.js?

The import is removed but the following issue is not closed yet:

Would love a clearer instruction for those who want to upgrade.

e.g. the svelteConfig is no longer needed if peer deps are upgraded to ~

@jycouet

jycouet commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

The import isn't gone - it's conditional.

sv now stores config in vite.config.js and ships no svelte.config.js. The eslint addon only adds the svelteConfig import when a real svelte.config.{js,ts} exists. With config in vite.config.js there's nothing importable, so we omit it on purpose: svelte-eslint-parser falls back to its defaults.

Upgrading an existing project:

  • Keep your svelte.config.js? Nothing to do - the import stays wired.
  • Moved config into vite.config.js and deleted svelte.config.js? Drop the import svelteConfig ... line and the svelteConfig entry in parserOptions. The parser defaults take over.

@hyunbinseo

Copy link
Copy Markdown
Contributor

explicitly importing allows for better compatibilty and functionality with rules and other tooling that depend on the config file. source

If I understood correctly:

  1. The explicit import is for better compatibility
  2. Svelte config defined in vite.confit.{js,ts} cannot be imported
  3. So the default eslint-plugin-svelte options are used for now
  4. If the following issue is resolved, explicit importing can be done, changing the status of 2

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.

3 participants