-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(image): Update image service config to allow passing settings to the service #6848
Conversation
🦋 Changeset detectedLatest commit: 4b6915f The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
* @type {'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | string} | ||
* @default `'astro/assets/services/squoosh'` | ||
* @type {{entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | string, config: Record<string, any>}} | ||
* @default `{entrypoint: 'astro/assets/services/squoosh', config?: {}}` | ||
* @version 2.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just curious because I don't know: Do we need to worry about updating the version number here since this specific configuration will only be appropriate for 2.3.x? (Even though image.service
itself was added in 2.1.0?)
Are we at all worried about this being misleading for someone who happens to be on a slightly older version of Astro before this update to the image service config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general implementation looks good to me
Changes
Certain image services need a separate config, this is applicable for both remote and local image services. For instance, you might want a setting to restrict the remote patterns supported. Or for remote services, maybe your service only support a certain amount of widths and heights, or you can set defaults etc etc.
It looks like this:
and the settings are passed to all the hooks as a second parameter:
Since we have a new shape, I also added utilities functions to
astro/assets
to set the service:Testing
Added a test
Docs
withastro/docs#3096