Fix assets not getting optimized when outDir is outside the CWD (#8670)

* 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
This commit is contained in:
Michaili K 2023-09-28 00:18:36 +02:00 committed by GitHub
parent 87d5b841af
commit e797b68160
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix asset optimization failing when outDir is outside the project directory

View file

@ -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;
@ -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;
}