@astrojs/cloudflare
Version:
Deploy your site to Cloudflare Workers/Pages
34 lines (33 loc) • 1.25 kB
JavaScript
import { passthroughImageService, sharpImageService } from "astro/config";
function setImageConfig(service, config, command, logger) {
switch (service) {
case "passthrough":
return { ...config, service: passthroughImageService() };
case "cloudflare":
return {
...config,
service: command === "dev" ? sharpImageService() : { entrypoint: "@astrojs/cloudflare/image-service" }
};
case "compile":
return {
...config,
service: sharpImageService(),
endpoint: {
entrypoint: command === "dev" ? void 0 : "@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 };
}
}
export {
setImageConfig
};