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,