File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -24,18 +24,27 @@ function run(cfg) {
2424}
2525
2626function main ( {
27+ profiles = { } ,
28+ // deprecated - to remove in next major
2729 runDefaultDirectives = new URLSearchParams ( 'w=480;1024;1920&format=avif;webp;jpg' ) ,
2830 defaultDirectives = new URLSearchParams ( ) ,
2931 exclude = '{build,dist,node_modules}/**/*' ,
3032 extendOutputFormats = ( i ) => i , //noop
3133 ...rest
3234} = { } ) {
35+ const dict = {
36+ run : runDefaultDirectives ,
37+ ...profiles
38+ }
3339 return imagetools ( {
34- defaultDirectives : ( url ) =>
35- url . searchParams . get ( 'as' ) ?. split ( ':' ) [ 0 ] === 'run'
36- ? runDefaultDirectives
37- : defaultDirectives ,
38- extendOutputFormats : ( builtins ) => ( { ...extendOutputFormats ( builtins ) , run } ) ,
40+ defaultDirectives : ( url ) => {
41+ const key = url . searchParams . get ( 'as' ) ?. split ( ':' ) [ 0 ]
42+ return Object . keys ( dict ) . includes ( key ) ? dict [ key ] : defaultDirectives
43+ } ,
44+ extendOutputFormats : ( builtins ) => ( {
45+ ...extendOutputFormats ( builtins ) ,
46+ ...Object . keys ( dict ) . reduce ( ( a , c ) => ( { ...a , [ c ] : run } ) , { } )
47+ } ) ,
3948 exclude,
4049 ...rest
4150 } )
You can’t perform that action at this time.
0 commit comments