Home / Function/ setImageConfig() — astro Function Reference

setImageConfig() — astro Function Reference

Architecture documentation for the setImageConfig() function in image-config.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  ce773f65_dbfe_caf7_c0b5_70177d93bbe3["setImageConfig()"]
  f4f77a1d_ebf2_80a3_83fc_469f07314c0b["image-config.ts"]
  ce773f65_dbfe_caf7_c0b5_70177d93bbe3 -->|defined in| f4f77a1d_ebf2_80a3_83fc_469f07314c0b
  style ce773f65_dbfe_caf7_c0b5_70177d93bbe3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/integrations/cloudflare/src/utils/image-config.ts lines 11–58

export function setImageConfig(
	service: ImageService,
	config: AstroConfig['image'],
	command: HookParameters<'astro:config:setup'>['command'],
	logger: AstroIntegrationLogger,
) {
	switch (service) {
		case 'passthrough':
			return { ...config, service: passthroughImageService() };

		case 'cloudflare':
			return {
				...config,
				service:
					command === 'dev'
						? sharpImageService()
						: { entrypoint: '@astrojs/cloudflare/image-service' },
			};
		case 'cloudflare-binding':
			return {
				...config,
				endpoint: {
					entrypoint: '@astrojs/cloudflare/image-transform-endpoint',
				},
			};

		case 'compile':
			return {
				...config,
				service: sharpImageService(),
				endpoint: {
					entrypoint: command === 'dev' ? undefined : '@astrojs/cloudflare/image-endpoint',
				},
			};

		case 'custom':
			return { ...config };

		default:
			if (config.service.entrypoint === 'astro/assets/services/sharp') {
				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 'passthrough' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice`,
				);
				return { ...config, service: passthroughImageService() };
			}
			return { ...config };
	}
}

Domain

Subdomains

Frequently Asked Questions

What does setImageConfig() do?
setImageConfig() is a function in the astro codebase, defined in packages/integrations/cloudflare/src/utils/image-config.ts.
Where is setImageConfig() defined?
setImageConfig() is defined in packages/integrations/cloudflare/src/utils/image-config.ts at line 11.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free