Skip to content

feat(next/image): add support for images.qualities in next.config #74257

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

Merged
merged 13 commits into from
Jan 3, 2025
Prev Previous commit
Next Next commit
add another test
  • Loading branch information
styfle committed Jan 2, 2025
commit 4eba8a8ce3d39652b2dd5d62b2fd5ce164dc8619
6 changes: 5 additions & 1 deletion packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,11 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
loaderFile: z.string().optional(),
minimumCacheTTL: z.number().int().gte(0).optional(),
path: z.string().optional(),
qualities: z.array(z.number().int().gte(1).lte(100)).max(20).optional(),
qualities: z
.array(z.number().int().gte(1).lte(100))
.min(1)
.max(20)
.optional(),
})
.optional(),
logging: z
Expand Down
27 changes: 26 additions & 1 deletion test/integration/image-optimizer/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,32 @@ describe('Image Optimizer', () => {
await nextConfig.restore()

expect(stderr).toContain(
`Array must be integer elements at "images.qualities"`
`Expected integer, received float at "images.qualities[3]"`
)
})

it('should error when qualities array is empty', async () => {
await nextConfig.replace(
'{ /* replaceme */ }',
JSON.stringify({
images: {
qualities: [],
},
})
)
let stderr = ''

app = await launchApp(appDir, await findPort(), {
onStderr(msg) {
stderr += msg || ''
},
})
await waitFor(1000)
await killApp(app).catch(() => {})
await nextConfig.restore()

expect(stderr).toContain(
`Array must contain at least 1 element(s) at "images.qualities"`
)
})

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy