@@ -19,6 +19,7 @@ export type LoaderOptions = {
1919 disable : boolean ;
2020 imagesHost : string ;
2121 host : string ;
22+ generateAvif : boolean ;
2223 } ;
2324 originalPixelRatio : Dpr ;
2425} ;
@@ -68,7 +69,7 @@ export const loader = function (this: webpack.loader.LoaderContext, source: stri
6869 ( a , b , imagePath ) => imagePath ,
6970 ) ;
7071
71- let webpSrcSet : SrcSet , originalExtensionSrcSet : SrcSet , data : OrderedBreakpointSource ;
72+ let avifSrcSet : SrcSet , webpSrcSet : SrcSet , originalExtensionSrcSet : SrcSet , data : OrderedBreakpointSource ;
7273 // Disables picture processing, srcSet is generated only for the original image type
7374 if ( options . imgproxy . disable ) {
7475 data = {
@@ -86,6 +87,7 @@ export const loader = function (this: webpack.loader.LoaderContext, source: stri
8687 } ;
8788 } else {
8889 const buildUrlsForPixelRatios = getImgproxyUrlBuilder ( options . imgproxy ) ;
90+ avifSrcSet = buildUrlsForPixelRatios ( pixelRatios , outputImagePath , 'avif' ) ;
8991 webpSrcSet = buildUrlsForPixelRatios ( pixelRatios , outputImagePath , 'webp' ) ;
9092 originalExtensionSrcSet = buildUrlsForPixelRatios (
9193 pixelRatios ,
@@ -107,6 +109,18 @@ export const loader = function (this: webpack.loader.LoaderContext, source: stri
107109 } ,
108110 ] ,
109111 } ;
112+
113+ if ( options . imgproxy . generateAvif ) {
114+ data . srcSets . unshift ( {
115+ extension : 'avif' ,
116+ srcSet : avifSrcSet ,
117+ } )
118+
119+ imageUrls . push (
120+ ...( Object . values ( avifSrcSet ) as string [ ] ) ,
121+ ) ;
122+ }
123+
110124 // Add links to images via imgproxy to the global object
111125 imageUrls . push (
112126 ...( Object . values ( webpSrcSet ) as string [ ] ) ,
0 commit comments