rsnext/packages/next/server/image-config.ts
Steven cc1f3b8a38
Add support for AVIF to next/image (#29683)
Add support for AVIF to `next/image`

- Fixes #27882 
- Closes #27432 

## Feature

- [x] Implements an existing feature request
- [x] Related issues linked
- [x] Integration tests added
- [x] Documentation added
- [x] Update manifest output
- [x] Warn when `sharp` is outdated
- [x] Errors & Warnings have helpful link attached
- [ ] Remove `image-size` in favor of `squoosh`/`sharp` (optional, need to benchmark)
2021-10-11 23:17:47 +00:00

35 lines
822 B
TypeScript

export const VALID_LOADERS = [
'default',
'imgix',
'cloudinary',
'akamai',
'custom',
] as const
export type LoaderValue = typeof VALID_LOADERS[number]
type ImageFormat = 'image/avif' | 'image/webp'
export type ImageConfigComplete = {
deviceSizes: number[]
imageSizes: number[]
loader: LoaderValue
path: string
domains?: string[]
disableStaticImages?: boolean
minimumCacheTTL?: number
formats?: ImageFormat[]
}
export type ImageConfig = Partial<ImageConfigComplete>
export const imageConfigDefault: ImageConfigComplete = {
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
path: '/_next/image',
loader: 'default',
domains: [],
disableStaticImages: false,
minimumCacheTTL: 60,
formats: ['image/avif', 'image/webp'],
}