diff --git a/packages/astro/src/assets/build/generate.ts b/packages/astro/src/assets/build/generate.ts index 84dd3ee68..b2004fad0 100644 --- a/packages/astro/src/assets/build/generate.ts +++ b/packages/astro/src/assets/build/generate.ts @@ -155,9 +155,7 @@ export async function generateImage( }; } -export function getStaticImageList(): Map< - string, { path: string; options: ImageTransform } -> { +export function getStaticImageList(): Map { if (!globalThis?.astroAsset?.staticImages) { return new Map(); } diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 494fcb327..111b8ef05 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -196,12 +196,20 @@ export async function generatePages(opts: StaticBuildOptions, internals: BuildIn } } - const staticImageList = getStaticImageList() + const staticImageList = getStaticImageList(); - if (staticImageList.size) logger.info(null, `\n${bgGreen(black(` generating optimized images `))}`); let count = 0; + if (staticImageList.size) + logger.info(null, `\n${bgGreen(black(` generating optimized images `))}`); + let count = 0; for (const imageData of staticImageList.entries()) { - count++ - await generateImage(pipeline, imageData[1].options, imageData[1].path, count, staticImageList.size); + count++; + await generateImage( + pipeline, + imageData[1].options, + imageData[1].path, + count, + staticImageList.size + ); } delete globalThis?.astroAsset?.addStaticImage; @@ -214,7 +222,13 @@ export async function generatePages(opts: StaticBuildOptions, internals: BuildIn logger.info(null, dim(`Completed in ${getTimeStat(timer, performance.now())}.\n`)); } -async function generateImage(pipeline: BuildPipeline, transform: ImageTransform, path: string, count: number, totalCount: number) { +async function generateImage( + pipeline: BuildPipeline, + transform: ImageTransform, + path: string, + count: number, + totalCount: number +) { const logger = pipeline.getLogger(); let timeStart = performance.now(); const generationData = await generateImageInternal(pipeline, transform, path); @@ -230,7 +244,10 @@ async function generateImage(pipeline: BuildPipeline, transform: ImageTransform, ? `(reused cache entry)` : `(before: ${generationData.weight.before}kB, after: ${generationData.weight.after}kB)`; const counter = `(${count}/${totalCount})`; - logger.info(null, ` ${green('▶')} ${path} ${dim(statsText)} ${dim(timeIncrease)} ${dim(counter)}}`); + logger.info( + null, + ` ${green('▶')} ${path} ${dim(statsText)} ${dim(timeIncrease)} ${dim(counter)}}` + ); } async function generatePage( @@ -394,10 +411,10 @@ function getInvalidRouteSegmentError( ...AstroErrorData.InvalidDynamicRoute, message: invalidParam ? AstroErrorData.InvalidDynamicRoute.message( - route.route, - JSON.stringify(invalidParam), - JSON.stringify(received) - ) + route.route, + JSON.stringify(invalidParam), + JSON.stringify(received) + ) : `Generated path for ${route.route} is invalid.`, hint, });