Skip to content

Commit 486a971

Browse files
authored
feat: better error message for preview if build output doesn't exist (#10337)
1 parent 7c07a88 commit 486a971

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.changeset/shy-colts-sniff.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+
feat: more helpful error for preview if build output doesn't exist

packages/kit/src/exports/vite/preview/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export async function preview(vite, vite_config, svelte_config) {
3636

3737
const dir = join(svelte_config.kit.outDir, 'output/server');
3838

39+
if (!fs.existsSync(dir)) {
40+
throw new Error(`Server files not found at ${dir}, did you run \`build\` first?`);
41+
}
42+
3943
/** @type {import('types').ServerInternalModule} */
4044
const { set_assets } = await import(pathToFileURL(join(dir, 'internal.js')).href);
4145

0 commit comments

Comments
 (0)