@@ -371,19 +371,24 @@ class HtmlWebpackPlugin {
371
371
if ( templateParameters === false ) {
372
372
return Promise . resolve ( { } ) ;
373
373
}
374
- if ( typeof templateParameters === 'function' ) {
375
- const preparedAssetTags = {
376
- headTags : this . prepareAssetTagGroupForRendering ( assetTags . headTags ) ,
377
- bodyTags : this . prepareAssetTagGroupForRendering ( assetTags . bodyTags )
378
- } ;
379
- return Promise
380
- . resolve ( )
381
- . then ( ( ) => templateParameters ( compilation , assets , preparedAssetTags , this . options ) ) ;
382
- }
383
- if ( typeof templateParameters === 'object' ) {
384
- return Promise . resolve ( templateParameters ) ;
374
+ if ( typeof templateParameters !== 'function' && typeof templateParameters !== 'object' ) {
375
+ throw new Error ( 'templateParameters has to be either a function or an object' ) ;
385
376
}
386
- throw new Error ( 'templateParameters has to be either a function or an object' ) ;
377
+ const templateParameterFunction = typeof templateParameters === 'function'
378
+ // A custom function can overwrite the entire template parameter preparation
379
+ ? templateParameters
380
+ // If the template parameters is an object merge it with the default values
381
+ : ( compilation , assets , assetTags , options ) => Object . assign ( { } ,
382
+ templateParametersGenerator ( compilation , assets , assetTags , options ) ,
383
+ templateParameters
384
+ ) ;
385
+ const preparedAssetTags = {
386
+ headTags : this . prepareAssetTagGroupForRendering ( assetTags . headTags ) ,
387
+ bodyTags : this . prepareAssetTagGroupForRendering ( assetTags . bodyTags )
388
+ } ;
389
+ return Promise
390
+ . resolve ( )
391
+ . then ( ( ) => templateParameterFunction ( compilation , assets , preparedAssetTags , this . options ) ) ;
387
392
}
388
393
389
394
/**
0 commit comments