Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the build directory in SvelteKit?

In SvelteKit, I can't figure out a way to change the path of the actual build directory (not the app or the generated directory) via configuration. I've tried changing it in Vite configuration (1) but I get the message (2).

1.

// vite.config.ts
import { sveltekit } from "@sveltejs/kit/vite"
import { defineConfig } from "vite"

export default defineConfig({
    plugins: [ sveltekit() ],
    build: { outDir: "builds" }
})
The following Vite config options will be overridden by SvelteKit:
  - build.outDir

For context, I'm making a mono-repo for a cross-platform app with the Vite generated SvelteKit build as a basis for the native platform apps.

like image 227
ko100 Avatar asked Oct 24 '25 15:10

ko100


1 Answers

With help from Patrick of the Svelte Discord I learned the correct configuration is the pages key in the adapter options (documentation.)

// svelte.config.js
import adapter from "@sveltejs/adapter-static"
import { vitePreprocess } from "@sveltejs/kit/vite"

/** @type {import("@sveltejs/kit").Config} */
const config = {
    // Consult https://kit.svelte.dev/docs/integrations#preprocessors
    // for more information about preprocessors
    preprocess: vitePreprocess(),

    kit: {
        adapter: adapter({ pages: "builds" })
    }
}

export default config
like image 116
ko100 Avatar answered Oct 27 '25 18:10

ko100



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!