From 3aaa0ea502d609b22258aa65de088eda108f19b9 Mon Sep 17 00:00:00 2001 From: Dominik G Date: Mon, 12 Dec 2022 13:15:13 +0100 Subject: [PATCH] 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 0a1db8c1 --- packages/vite/src/node/preview.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/vite/src/node/preview.ts b/packages/vite/src/node/preview.ts index 6791519d6808a0..3a5cbc0c8e566c 100644 --- a/packages/vite/src/node/preview.ts +++ b/packages/vite/src/node/preview.ts @@ -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' @@ -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, @@ -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,