Skip to content

Commit 2a2f798

Browse files
committed
[breaking] require vite.config.js
1 parent 3eb26e4 commit 2a2f798

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

.changeset/hip-trainers-sort.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[breaking] require vite.config.js

packages/kit/src/cli.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,9 @@ function welcome({ port, host, https, open, base, loose, allow, cwd }) {
283283
}
284284

285285
/**
286-
* @param {import('types').ValidatedConfig} svelte_config
287286
* @return {Promise<import('vite').UserConfig>}
288287
*/
289-
export async function get_vite_config(svelte_config) {
288+
export async function get_vite_config() {
290289
for (const file of ['vite.config.js', 'vite.config.mjs', 'vite.config.cjs']) {
291290
if (fs.existsSync(file)) {
292291
// TODO warn here if config.kit.vite was specified
@@ -298,10 +297,5 @@ export async function get_vite_config(svelte_config) {
298297
}
299298
}
300299

301-
const { sveltekit } = await import('./vite/index.js');
302-
303-
// TODO: stop reading Vite config from SvelteKit config or move to CLI
304-
const vite_config = await svelte_config.kit.vite();
305-
vite_config.plugins = [...(vite_config.plugins || []), ...sveltekit()];
306-
return vite_config;
300+
throw new Error('vite.config.js is missing. See an example here: https://github.com/sveltejs/kit/blob/master/packages/create-svelte/templates/skeleton/vite.config.js');
307301
}

packages/kit/src/core/config/options.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ const options = object(
278278
// TODO remove this for 1.0
279279
ssr: error(
280280
(keypath) =>
281-
`${keypath} has been removed — use the handle hook instead: https://kit.svelte.dev/docs/hooks#handle'`
281+
`${keypath} has been removed — use the handle hook instead: https://kit.svelte.dev/docs/hooks#handle`
282282
),
283283

284284
// TODO remove this for 1.0
@@ -291,22 +291,10 @@ const options = object(
291291
pollInterval: number(0)
292292
}),
293293

294-
vite: validate(
295-
() => ({}),
296-
(input, keypath) => {
297-
if (typeof input === 'object') {
298-
const config = input;
299-
input = () => config;
300-
}
301-
302-
if (typeof input !== 'function') {
303-
throw new Error(
304-
`${keypath} must be a Vite config object (https://vitejs.dev/config) or a function that returns one`
305-
);
306-
}
307-
308-
return input;
309-
}
294+
// TODO remove this for 1.0
295+
vite: error(
296+
(keypath) =>
297+
`${keypath} has been removed — use vite.config.js instead`
310298
)
311299
})
312300
},

0 commit comments

Comments
 (0)