From e797b6816072f63f38d9a91dd2a66765c558d46c Mon Sep 17 00:00:00 2001 From: Michaili K Date: Thu, 28 Sep 2023 00:18:36 +0200 Subject: [PATCH] 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 --- .changeset/little-onions-relax.md | 5 +++++ packages/astro/src/assets/build/generate.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/little-onions-relax.md diff --git a/.changeset/little-onions-relax.md b/.changeset/little-onions-relax.md new file mode 100644 index 0000000000..820b0a40eb --- /dev/null +++ b/.changeset/little-onions-relax.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix asset optimization failing when outDir is outside the project directory diff --git a/packages/astro/src/assets/build/generate.ts b/packages/astro/src/assets/build/generate.ts index dfc0d9a0d2..613b80ee04 100644 --- a/packages/astro/src/assets/build/generate.ts +++ b/packages/astro/src/assets/build/generate.ts @@ -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; }