Check vite.emptyOutDir before emptying dir (#6153)

* Check vite.emptyOutDir before emptying dir

* Fix: add .build to object path

* Update packages/astro/src/core/build/static-build.ts

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>

* Create flat-dolphins-admire.md

---------

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
Isaac 2023-02-06 16:16:46 -04:00 committed by GitHub
parent 9fdecb5606
commit 1b591a1431
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"astro": patch
---
Respect `vite.build.emptyOutDir` setting during `astro build`

View file

@ -61,7 +61,9 @@ export async function staticBuild(opts: StaticBuildOptions) {
// Empty out the dist folder, if needed. Vite has a config for doing this
// but because we are running 2 vite builds in parallel, that would cause a race
// condition, so we are doing it ourselves
emptyDir(settings.config.outDir, new Set('.git'));
if (settings.config?.vite?.build?.emptyOutDir !== false) {
emptyDir(settings.config.outDir, new Set('.git'));
}
// Register plugins
const container = createPluginContainer(opts, internals);