summaryrefslogtreecommitdiff
path: root/packages/integrations/cloudflare/src
diff options
context:
space:
mode:
authorGravatar Alexander Niebuhr <alexander@nbhr.io> 2023-10-24 11:29:57 +0200
committerGravatar GitHub <noreply@github.com> 2023-10-24 10:29:57 +0100
commitd944d29f4ad5c651c59ffa3fb23132988662f13c (patch)
treebb9e6fed63bf8a5c65fc141a09946ba906c1f16d /packages/integrations/cloudflare/src
parent0bdec42e5c4c7afd25a5a72c9e9e12d107e1d387 (diff)
downloadastro-d944d29f4ad5c651c59ffa3fb23132988662f13c.tar.gz
astro-d944d29f4ad5c651c59ffa3fb23132988662f13c.tar.zst
astro-d944d29f4ad5c651c59ffa3fb23132988662f13c.zip
fix(cloudflare): astro asset image service (#33)
* fix(cloudflare): astro asset image service * fix ci/cd * resolve review comments Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> Co-authored-by: Voxel <20650404+VoxelMC@users.noreply.github.com> Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> --------- Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com> Co-authored-by: Voxel <20650404+VoxelMC@users.noreply.github.com> Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/cloudflare/src')
-rw-r--r--packages/integrations/cloudflare/src/index.ts14
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts
index 0ee5fd945..6696c7b9e 100644
--- a/packages/integrations/cloudflare/src/index.ts
+++ b/packages/integrations/cloudflare/src/index.ts
@@ -1,6 +1,7 @@
import type { AstroConfig, AstroIntegration, RouteData } from 'astro';
import { createRedirectsFromAstroRoutes } from '@astrojs/underscore-redirects';
+import { passthroughImageService } from 'astro/config';
import { AstroError } from 'astro/errors';
import esbuild from 'esbuild';
import { Miniflare } from 'miniflare';
@@ -104,7 +105,17 @@ export default function createIntegration(args?: Options): AstroIntegration {
return {
name: '@astrojs/cloudflare',
hooks: {
- 'astro:config:setup': ({ config, updateConfig }) => {
+ 'astro:config:setup': ({ config, updateConfig, logger }) => {
+ let imageConfigOverwrite = false;
+ if (
+ config.image.service.entrypoint === 'astro/assets/services/sharp' ||
+ config.image.service.entrypoint === 'astro/assets/services/squoosh'
+ ) {
+ logger.warn(
+ `The current configuration 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`
+ );
+ imageConfigOverwrite = true;
+ }
updateConfig({
build: {
client: new URL(`.${config.base}`, config.outDir),
@@ -121,6 +132,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
}),
],
},
+ image: imageConfigOverwrite ? passthroughImageService() : config.image,
});
},
'astro:config:done': ({ setAdapter, config, logger }) => {