summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Isaac <isaac.alexander.smith@gmail.com> 2023-02-06 16:16:46 -0400
committerGravatar GitHub <noreply@github.com> 2023-02-06 14:16:46 -0600
commit1b591a1431b44eacd239ed8f76809916cabca1db (patch)
tree43fe3cf58df9ac2abf4707210850946013a12091
parent9fdecb5606f14d277f56b58f3d06d7ad6c0c515c (diff)
downloadastro-1b591a1431b44eacd239ed8f76809916cabca1db.tar.gz
astro-1b591a1431b44eacd239ed8f76809916cabca1db.tar.zst
astro-1b591a1431b44eacd239ed8f76809916cabca1db.zip
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>
Diffstat (limited to '')
-rw-r--r--.changeset/flat-dolphins-admire.md5
-rw-r--r--packages/astro/src/core/build/static-build.ts4
2 files changed, 8 insertions, 1 deletions
diff --git a/.changeset/flat-dolphins-admire.md b/.changeset/flat-dolphins-admire.md
new file mode 100644
index 000000000..787a108b7
--- /dev/null
+++ b/.changeset/flat-dolphins-admire.md
@@ -0,0 +1,5 @@
+---
+"astro": patch
+---
+
+Respect `vite.build.emptyOutDir` setting during `astro build`
diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts
index aef8a1aab..1a6d3e367 100644
--- a/packages/astro/src/core/build/static-build.ts
+++ b/packages/astro/src/core/build/static-build.ts
@@ -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);