Skip to content

Commit

Permalink
fix(preview): Revert vitejs#10564 - throw Error on missing outDir (vi…
Browse files Browse the repository at this point in the history
…tejs#11335)

fix(preview): Revert "fix: check if build exists so preview doesn't show 404s due to nonexistent build (vitejs#10564)"

This reverts commit 0a1db8c
  • Loading branch information
dominikg authored and futurGH committed Feb 26, 2023
1 parent 4df9e80 commit 44e87ef
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 44e87ef

Please sign in to comment.