Skip to content

Commit 8020bd7

Browse files
benbalterCopilot
andcommitted
Add Sharp codec-specific image encoding defaults
New in Astro 6.1: configure JPEG, WebP, AVIF, and PNG encoding once globally rather than per-image. Enables mozjpeg for JPEG and bumps WebP/AVIF effort levels for better compression on built images. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 88cb54d commit 8020bd7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

astro.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ export default defineConfig({
119119
layout: 'constrained',
120120
// Add global responsive image styles
121121
responsiveStyles: true,
122+
// Codec-specific encoding defaults (Astro 6.1+)
123+
// Applied to every image processed by Sharp during the build.
124+
// Per-image `quality` still takes precedence when set.
125+
service: {
126+
config: {
127+
jpeg: { mozjpeg: true },
128+
webp: { effort: 6 },
129+
avif: { effort: 4 },
130+
png: { compressionLevel: 9 },
131+
},
132+
},
122133
domains: [
123134
// Amazon book covers (used in other-recommended-reading page)
124135
'images.amazon.com',

0 commit comments

Comments
 (0)