Skip to content

Commit

Permalink
fix(environment): use client environment build.outDir for preview
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Mar 29, 2024
1 parent a1d385c commit 6002791
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vite/src/node/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ export async function preview(
true,
)

const distDir = path.resolve(config.root, config.build.outDir)
const clientOutDir =
config.environments.client.build.outDir ?? config.build.outDir
const distDir = path.resolve(config.root, clientOutDir)
if (
!fs.existsSync(distDir) &&
// error if no plugins implement `configurePreviewServer`
Expand All @@ -122,7 +124,7 @@ export async function preview(
process.argv[2] === 'preview'
) {
throw new Error(
`The directory "${config.build.outDir}" does not exist. Did you build your project?`,
`The directory "${clientOutDir}" does not exist. Did you build your project?`,
)
}

Expand Down

0 comments on commit 6002791

Please sign in to comment.