Skip to content

fix(build): copy public directory after building same environment with write=false#22328

Merged
sapphi-red merged 2 commits into
vitejs:mainfrom
artemxknpv:fix-public-dir-after-write-false
May 14, 2026
Merged

fix(build): copy public directory after building same environment with write=false#22328
sapphi-red merged 2 commits into
vitejs:mainfrom
artemxknpv:fix-public-dir-after-write-false

Conversation

@artemxknpv
Copy link
Copy Markdown
Contributor

fixes #22305

prepareOutDirPlugin was marking an environment as rendered even when build.write was false. If the same environment was built again with write set back to true, prepareOutDir() was skipped and publicDir was not copied.

This only marks the environment as rendered when prepareOutDir() actually runs.

Added a regression test for building the same client environment with write: false first and write: true second.

Checks:

  • pnpm --filter vite build
  • pnpm test-unit build
  • pnpm --filter vite typecheck
  • pnpm exec eslint --cache --concurrency auto packages/vite/src/node/plugins/prepareOutDir.ts packages/vite/src/node/__tests__/build.spec.ts

@artemxknpv artemxknpv force-pushed the fix-public-dir-after-write-false branch from ec8e139 to c48b58b Compare April 27, 2026 15:11
@artemxknpv artemxknpv marked this pull request as ready for review April 27, 2026 15:22
@artemxknpv artemxknpv force-pushed the fix-public-dir-after-write-false branch from c48b58b to 05be609 Compare April 27, 2026 15:34
@artemxknpv artemxknpv force-pushed the fix-public-dir-after-write-false branch from 05be609 to 6df7ba6 Compare April 29, 2026 09:29
@artemxknpv
Copy link
Copy Markdown
Contributor Author

@bluwy hi, quick check: is this still worth a look?

CI is green now. happy to adjust if you’d prefer a different approach.

@sapphi-red sapphi-red added feat: build p2-edge-case Bug, but has workaround or limited in scope (priority) labels May 14, 2026
@sapphi-red sapphi-red changed the title fix(build): prepare outDir after write false build fix(build): copy public directory after building same environment with write=false May 14, 2026
Copy link
Copy Markdown
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sapphi-red sapphi-red merged commit 158e8ae into vitejs:main May 14, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: build p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

public directory is not copied when building twice with write: false and then write: true

2 participants