Skip to content

Commit

Permalink
Update example to account for object merging
Browse files Browse the repository at this point in the history
PR #1331 introduces new behavior that merges a passed object with the
defaults.
  • Loading branch information
genderquery authored and jantimon committed Apr 28, 2020
1 parent 44c6d58 commit 4785281
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions examples/template-parameters/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ module.exports = {
},
plugins: [
new HtmlWebpackPlugin({
// NOTE if you pass plain object it will be passed as is. no default values there, so be aware!
// for implementation detail, please see index.js and search for "userOptions" variable
templateParameters: (compilation, assets, assetTags, options) => {
return {
compilation,
webpackConfig: compilation.options,
htmlWebpackPlugin: {
tags: assetTags,
files: assets,
options
},
'foo': 'bar'
};
// If you pass a plain object, it will be merged with the default values
// (New in version 4)
templateParameters: {
'foo': 'bar'
},
// Or if you want full control, pass a function
// templateParameters: (compilation, assets, assetTags, options) => {
// return {
// compilation,
// webpackConfig: compilation.options,
// htmlWebpackPlugin: {
// tags: assetTags,
// files: assets,
// options
// },
// 'foo': 'bar'
// };
// },
template: 'index.ejs'
})
]
Expand Down

0 comments on commit 4785281

Please sign in to comment.