Skip to content

Commit

Permalink
fix(preview): Revert #10564 - throw Error on missing outDir (#11335)
Browse files Browse the repository at this point in the history
fix(preview): Revert "fix: check if build exists so preview doesn't show 404s due to nonexistent build (#10564)"

This reverts commit 0a1db8c
  • Loading branch information
dominikg authored Dec 12, 2022
1 parent e58a4f0 commit 3aaa0ea
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions packages/vite/src/node/preview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fs from 'node:fs'
import path from 'node:path'
import type * as http from 'node:http'
import sirv from 'sirv'
Expand Down Expand Up @@ -84,13 +83,6 @@ export async function preview(
'production',
)

const distDir = path.resolve(config.root, config.build.outDir)
if (!fs.existsSync(distDir)) {
throw new Error(
`"${config.build.outDir}" does not exist. Did you build your project?`,
)
}

const app = connect() as Connect.Server
const httpServer = await resolveHttpServer(
config.preview,
Expand Down Expand Up @@ -123,6 +115,7 @@ export async function preview(
config.base === './' || config.base === '' ? '/' : config.base

// static assets
const distDir = path.resolve(config.root, config.build.outDir)
const headers = config.preview.headers
const assetServer = sirv(distDir, {
etag: true,
Expand Down

0 comments on commit 3aaa0ea

Please sign in to comment.