Skip to content

Commit

Permalink
feat(cloudflare): add imageService 'custom' (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianFlatscher authored Apr 10, 2024
1 parent efb597b commit 1f4e40b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/stupid-houses-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': minor
---

Adds a new option for the Image service to the Cloudflare adapter. `imageService: 'custom'` does use the user defined settings, without applying any modification to it. **You need to make sure that the configured settings are compatible with Cloudflare's `workerd` runtime yourself.**
2 changes: 1 addition & 1 deletion packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type { Runtime } from './entrypoints/server.js';

export type Options = {
/** Options for handling images. */
imageService?: 'passthrough' | 'cloudflare' | 'compile';
imageService?: 'passthrough' | 'cloudflare' | 'compile' | 'custom';
/** Configuration for `_routes.json` generation. A _routes.json file controls when your Function is invoked. This file will include three different properties:
*
* - version: Defines the version of the schema. Currently there is only one version of the schema (version 1), however, we may add more in the future and aim to be backwards compatible.
Expand Down
3 changes: 3 additions & 0 deletions packages/cloudflare/src/utils/image-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export function setImageConfig(
endpoint: command === 'dev' ? undefined : '@astrojs/cloudflare/image-endpoint',
};

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

default:
if (
config.service.entrypoint === 'astro/assets/services/sharp' ||
Expand Down

0 comments on commit 1f4e40b

Please sign in to comment.