Skip to content

Commit 3aaa0ea

Browse files
authoredDec 12, 2022
fix(preview): Revert #10564 - throw Error on missing outDir (#11335)
fix(preview): Revert "fix: check if build exists so preview doesn't show 404s due to nonexistent build (#10564)" This reverts commit 0a1db8c
1 parent e58a4f0 commit 3aaa0ea

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed
 

‎packages/vite/src/node/preview.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fs from 'node:fs'
21
import path from 'node:path'
32
import type * as http from 'node:http'
43
import sirv from 'sirv'
@@ -84,13 +83,6 @@ export async function preview(
8483
'production',
8584
)
8685

87-
const distDir = path.resolve(config.root, config.build.outDir)
88-
if (!fs.existsSync(distDir)) {
89-
throw new Error(
90-
`"${config.build.outDir}" does not exist. Did you build your project?`,
91-
)
92-
}
93-
9486
const app = connect() as Connect.Server
9587
const httpServer = await resolveHttpServer(
9688
config.preview,
@@ -123,6 +115,7 @@ export async function preview(
123115
config.base === './' || config.base === '' ? '/' : config.base
124116

125117
// static assets
118+
const distDir = path.resolve(config.root, config.build.outDir)
126119
const headers = config.preview.headers
127120
const assetServer = sirv(distDir, {
128121
etag: true,

0 commit comments

Comments
 (0)
Please sign in to comment.