npmsveltesveltekit

svelte.config.js: Unexpected option config.kit.vite


I just started learning Svelte/kit, I stated a small project to learn, I wanted a calendar. I found svelte-calendar package in npm. I installed the package,

npm i svelte-calendar

And I set this in svelte.config.js

import adapter from '@sveltejs/adapter-auto';

const config = {
    kit: {
        adapter: adapter(),

        vite: {
            optimizeDeps: {
                include: ['just-throttle', 'dayjs']
            }
        }
    }
};

export default config;

Why am I getting this error when I run

npm run dev

This is my fist time working with Svelte-kit and npm so I don't have much idea on this.


Solution

  • At some point this was changed, and if you put a vite config object inside of kit, you will get this error:

    error during build:
    Could not load svelte.config.js: Unexpected option config.kit.vite
    

    Vite options should now be set directly in the regular Vite config file: vite.config.js/.ts. You will have both svelte.config.js and vite.config.js (or .ts).

    Docs for optimizeDeps