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
renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 16, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | vite    | 8.0.11 | 8.0.13 |


## [v8.0.13](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-8013-2026-05-14-small)

##### Features

- **bundled-dev:** add lazy bundling support ([#21406](vitejs/vite#21406)) ([4f0949f](vitejs/vite@4f0949f))
- **optimizer:** improve the esbuild plugin converter to pass some properties of build result to `onEnd` ([#22357](vitejs/vite#22357)) ([47071ce](vitejs/vite@47071ce))
- update rolldown to 1.0.1 ([#22444](vitejs/vite#22444)) ([8c766a6](vitejs/vite@8c766a6))

##### Bug Fixes

- **build:** copy public directory after building same environment with `write=false` ([#22328](vitejs/vite#22328)) ([158e8ae](vitejs/vite@158e8ae))
- **css:** await sass/less/styl worker disposal on teardown (fix [#22274](vitejs/vite#22274)) ([#22275](vitejs/vite#22275)) ([b7edcb7](vitejs/vite@b7edcb7))
- **css:** keep deprecated `name`/`originalFileName` in synthetic `assetFileNames` call ([#22439](vitejs/vite#22439)) ([8e59c97](vitejs/vite@8e59c97))
- make `isBundled` per environment ([#22257](vitejs/vite#22257)) ([a576326](vitejs/vite@a576326))
- **ssr:** avoid rewriting labels that collide with imports ([#22451](vitejs/vite#22451)) ([d9b18e0](vitejs/vite@d9b18e0))

##### Miscellaneous Chores

- remove irrelevant commits from changelog ([#22430](vitejs/vite#22430)) ([6ea3838](vitejs/vite@6ea3838))
- update changelog ([#22413](vitejs/vite#22413)) ([fcdc87c](vitejs/vite@fcdc87c))


## [v8.0.12](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-8012-2026-05-11-small)

##### Features

- update rolldown to 1.0.0 ([#22401](vitejs/vite#22401)) ([cf0ff41](vitejs/vite@cf0ff41))

##### Bug Fixes

- **create-vite:** pass react framework to TanStack CLI ([#22397](vitejs/vite#22397)) ([18f0f90](vitejs/vite@18f0f90))
- **deps:** update all non-major dependencies ([#22420](vitejs/vite#22420)) ([2be6000](vitejs/vite@2be6000))
- **module-runner:** prevent partial-exports race on concurrent imports of in-flight invalidated re-export chains ([#22369](vitejs/vite#22369)) ([f5a22e6](vitejs/vite@f5a22e6))
- refer to `rolldownOptions` instead of deprecated `rollupOptions` in messages ([#22400](vitejs/vite#22400)) ([b675c7b](vitejs/vite@b675c7b))
- **worker:** apply `build.target` to worker bundle ([#22404](vitejs/vite#22404)) ([3c93fde](vitejs/vite@3c93fde))
- **worker:** forward define to worker bundle transform ([#22408](vitejs/vite#22408)) ([d4838a0](vitejs/vite@d4838a0))

##### Miscellaneous Chores

- **deps:** update dependency eslint-plugin-n to v18 ([#22423](vitejs/vite#22423)) ([2fe7bd2](vitejs/vite@2fe7bd2))
- **deps:** update rolldown-related dependencies ([#22421](vitejs/vite#22421)) ([66b9eb3](vitejs/vite@66b9eb3))
renovate Bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 17, 2026
| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | vite    | 8.0.11 | 8.0.13 |


## [v8.0.13](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-8013-2026-05-14-small)

##### Features

- **bundled-dev:** add lazy bundling support ([#21406](vitejs/vite#21406)) ([4f0949f](vitejs/vite@4f0949f))
- **optimizer:** improve the esbuild plugin converter to pass some properties of build result to `onEnd` ([#22357](vitejs/vite#22357)) ([47071ce](vitejs/vite@47071ce))
- update rolldown to 1.0.1 ([#22444](vitejs/vite#22444)) ([8c766a6](vitejs/vite@8c766a6))

##### Bug Fixes

- **build:** copy public directory after building same environment with `write=false` ([#22328](vitejs/vite#22328)) ([158e8ae](vitejs/vite@158e8ae))
- **css:** await sass/less/styl worker disposal on teardown (fix [#22274](vitejs/vite#22274)) ([#22275](vitejs/vite#22275)) ([b7edcb7](vitejs/vite@b7edcb7))
- **css:** keep deprecated `name`/`originalFileName` in synthetic `assetFileNames` call ([#22439](vitejs/vite#22439)) ([8e59c97](vitejs/vite@8e59c97))
- make `isBundled` per environment ([#22257](vitejs/vite#22257)) ([a576326](vitejs/vite@a576326))
- **ssr:** avoid rewriting labels that collide with imports ([#22451](vitejs/vite#22451)) ([d9b18e0](vitejs/vite@d9b18e0))

##### Miscellaneous Chores

- remove irrelevant commits from changelog ([#22430](vitejs/vite#22430)) ([6ea3838](vitejs/vite@6ea3838))
- update changelog ([#22413](vitejs/vite#22413)) ([fcdc87c](vitejs/vite@fcdc87c))


## [v8.0.12](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-8012-2026-05-11-small)

##### Features

- update rolldown to 1.0.0 ([#22401](vitejs/vite#22401)) ([cf0ff41](vitejs/vite@cf0ff41))

##### Bug Fixes

- **create-vite:** pass react framework to TanStack CLI ([#22397](vitejs/vite#22397)) ([18f0f90](vitejs/vite@18f0f90))
- **deps:** update all non-major dependencies ([#22420](vitejs/vite#22420)) ([2be6000](vitejs/vite@2be6000))
- **module-runner:** prevent partial-exports race on concurrent imports of in-flight invalidated re-export chains ([#22369](vitejs/vite#22369)) ([f5a22e6](vitejs/vite@f5a22e6))
- refer to `rolldownOptions` instead of deprecated `rollupOptions` in messages ([#22400](vitejs/vite#22400)) ([b675c7b](vitejs/vite@b675c7b))
- **worker:** apply `build.target` to worker bundle ([#22404](vitejs/vite#22404)) ([3c93fde](vitejs/vite@3c93fde))
- **worker:** forward define to worker bundle transform ([#22408](vitejs/vite#22408)) ([d4838a0](vitejs/vite@d4838a0))

##### Miscellaneous Chores

- **deps:** update dependency eslint-plugin-n to v18 ([#22423](vitejs/vite#22423)) ([2fe7bd2](vitejs/vite@2fe7bd2))
- **deps:** update rolldown-related dependencies ([#22421](vitejs/vite#22421)) ([66b9eb3](vitejs/vite@66b9eb3))
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