diff --git a/.changeset/stale-dragons-invite.md b/.changeset/stale-dragons-invite.md new file mode 100644 index 000000000..a967daecc --- /dev/null +++ b/.changeset/stale-dragons-invite.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Improve the logging of assets for adapters that do not support image optimization diff --git a/packages/astro/src/integrations/astroFeaturesValidation.ts b/packages/astro/src/integrations/astroFeaturesValidation.ts index 7f40479f3..3231b1577 100644 --- a/packages/astro/src/integrations/astroFeaturesValidation.ts +++ b/packages/astro/src/integrations/astroFeaturesValidation.ts @@ -131,7 +131,7 @@ function validateAssetsFeature( isSquooshCompatible = false, } = assets; if (config?.image?.service?.entrypoint === SHARP_SERVICE && !isSharpCompatible) { - logger.error( + logger.warn( 'astro', `The currently selected adapter \`${adapterName}\` is not compatible with the image service "Sharp".` ); @@ -139,7 +139,7 @@ function validateAssetsFeature( } if (config?.image?.service?.entrypoint === SQUOOSH_SERVICE && !isSquooshCompatible) { - logger.error( + logger.warn( 'astro', `The currently selected adapter \`${adapterName}\` is not compatible with the image service "Squoosh".` ); diff --git a/packages/astro/src/integrations/index.ts b/packages/astro/src/integrations/index.ts index 92f277872..c5c92a4e4 100644 --- a/packages/astro/src/integrations/index.ts +++ b/packages/astro/src/integrations/index.ts @@ -221,7 +221,11 @@ export async function runHookConfigDone({ logger ); for (const [featureName, supported] of Object.entries(validationResult)) { - if (!supported) { + // If `supported` / `validationResult[featureName]` only allows boolean, + // in theory 'assets' false, doesn't mean that the feature is not supported, but rather that the chosen image service is unsupported + // in this case we should not show an error, that the featrue is not supported + // if we would refactor the validation to support more than boolean, we could still be able to differentiate between the two cases + if (!supported && featureName !== 'assets') { logger.error( 'astro', `The adapter ${adapter.name} doesn't support the feature ${featureName}. Your project won't be built. You should not use it.` @@ -229,9 +233,9 @@ export async function runHookConfigDone({ } } if (!validationResult.assets) { - logger.info( + logger.warn( 'astro', - `The selected adapter ${adapter.name} does not support Sharp or Squoosh for image processing. To ensure your project is still able to build, image processing has been disabled.` + `The selected adapter ${adapter.name} does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice` ); settings.config.image.service = { entrypoint: 'astro/assets/services/noop',