summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexander Niebuhr <alexander@nbhr.io> 2023-09-23 18:15:49 +0200
committerGravatar GitHub <noreply@github.com> 2023-09-23 18:15:49 +0200
commit4c4ad9d167e8d15ff2c15e3336ede8ca22f646b2 (patch)
treead4d7839e81df3b08f70df5dd4396f9489eba9aa
parent1d4f91b033b70f6d863698acea8722d7ad8e50b9 (diff)
downloadastro-4c4ad9d167e8d15ff2c15e3336ede8ca22f646b2.tar.gz
astro-4c4ad9d167e8d15ff2c15e3336ede8ca22f646b2.tar.zst
astro-4c4ad9d167e8d15ff2c15e3336ede8ca22f646b2.zip
chore(core): improve the logging of assets feature (#8615)
* improve assets logging * changeset * fix typo Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> * improve log message Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * update log message * update changeset --------- Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
-rw-r--r--.changeset/stale-dragons-invite.md5
-rw-r--r--packages/astro/src/integrations/astroFeaturesValidation.ts4
-rw-r--r--packages/astro/src/integrations/index.ts10
3 files changed, 14 insertions, 5 deletions
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',