diff --git a/.changeset/ninety-spoons-thank.md b/.changeset/ninety-spoons-thank.md new file mode 100644 index 000000000000..0320919b15a0 --- /dev/null +++ b/.changeset/ninety-spoons-thank.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: Allow sveltkit root to be properly set diff --git a/packages/kit/src/exports/vite/index.js b/packages/kit/src/exports/vite/index.js index e6521e979560..b9c9c2ff4eac 100644 --- a/packages/kit/src/exports/vite/index.js +++ b/packages/kit/src/exports/vite/index.js @@ -125,10 +125,14 @@ const warning_preprocessor = { /** * Returns the SvelteKit Vite plugins. + * @param {{ root?: string }} config * @returns {Promise} */ -export async function sveltekit() { - const svelte_config = await load_config(); +export async function sveltekit(config = {}) { + const options = { + cwd: config.root ? config.root : process.cwd() + }; + const svelte_config = await load_config(options); /** @type {import('@sveltejs/vite-plugin-svelte').Options['preprocess']} */ let preprocess = svelte_config.preprocess; diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 237b3e3ff57e..77f97f20032a 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -1961,7 +1961,9 @@ declare module '@sveltejs/kit/vite' { /** * Returns the SvelteKit Vite plugins. * */ - export function sveltekit(): Promise; + export function sveltekit(config?: { + root?: string; + }): Promise; export {}; }