Skip to content

Commit

Permalink
fix(environment): use environments.client.build.outDir for preview (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Apr 6, 2024
1 parent 5f3c44f commit 8621c3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 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
3 changes: 0 additions & 3 deletions playground/environment-react-ssr/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ export default defineConfig((env) => ({
},
},

// [feedback] should preview automatically pick up environments.client.build.outDir?
build: env.isPreview ? { outDir: 'dist/client' } : {},

builder: {
async buildEnvironments(builder, build) {
await build(builder.environments.client)
Expand Down

0 comments on commit 8621c3f

Please sign in to comment.