Skip to content

Commit

Permalink
Check vite.emptyOutDir before emptying dir (#6153)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
torchsmith and natemoo-re authored Feb 6, 2023
1 parent 9fdecb5 commit 1b591a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/flat-dolphins-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Respect `vite.build.emptyOutDir` setting during `astro build`
4 changes: 3 additions & 1 deletion packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1b591a1

Please sign in to comment.