Skip to content

Commit

Permalink
Fix assets not getting optimized when outDir is outside the CWD (#8670
Browse files Browse the repository at this point in the history
)

* Fix assets not getting optimized when `outDir` is outside the CWD

* Add missing import

* Add changeset

* Fix import, again.

* Use getOutDirWithinCwd in the serverRoot declaration
  • Loading branch information
MichailiK committed Sep 27, 2023
1 parent 87d5b84 commit e797b68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/little-onions-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix asset optimization failing when outDir is outside the project directory
3 changes: 2 additions & 1 deletion packages/astro/src/assets/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getConfiguredImageService, isESMImportedImage } from '../internal.js';
import type { LocalImageService } from '../services/service.js';
import type { ImageMetadata, ImageTransform } from '../types.js';
import { loadRemoteImage, type RemoteCacheEntry } from './remote.js';
import { getOutDirWithinCwd } from "../../core/build/common.js";

interface GenerationDataUncached {
cached: false;
Expand Down Expand Up @@ -48,7 +49,7 @@ export async function generateImage(
serverRoot = config.build.server;
clientRoot = config.build.client;
} else {
serverRoot = config.outDir;
serverRoot = getOutDirWithinCwd(config.outDir);
clientRoot = config.outDir;
}

Expand Down

0 comments on commit e797b68

Please sign in to comment.