Skip to content

Commit

Permalink
feat: better error message for preview if build output doesn't exist (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gtm-nayan authored Jul 7, 2023
1 parent 7c07a88 commit 486a971
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-colts-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

feat: more helpful error for preview if build output doesn't exist
4 changes: 4 additions & 0 deletions packages/kit/src/exports/vite/preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export async function preview(vite, vite_config, svelte_config) {

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

if (!fs.existsSync(dir)) {
throw new Error(`Server files not found at ${dir}, did you run \`build\` first?`);
}

/** @type {import('types').ServerInternalModule} */
const { set_assets } = await import(pathToFileURL(join(dir, 'internal.js')).href);

Expand Down

0 comments on commit 486a971

Please sign in to comment.