Skip to content

Commit 4785281

Browse files
genderqueryjantimon
authored andcommitted
Update example to account for object merging
PR #1331 introduces new behavior that merges a passed object with the defaults.
1 parent 44c6d58 commit 4785281

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

examples/template-parameters/webpack.config.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@ module.exports = {
1111
},
1212
plugins: [
1313
new HtmlWebpackPlugin({
14-
// NOTE if you pass plain object it will be passed as is. no default values there, so be aware!
15-
// for implementation detail, please see index.js and search for "userOptions" variable
16-
templateParameters: (compilation, assets, assetTags, options) => {
17-
return {
18-
compilation,
19-
webpackConfig: compilation.options,
20-
htmlWebpackPlugin: {
21-
tags: assetTags,
22-
files: assets,
23-
options
24-
},
25-
'foo': 'bar'
26-
};
14+
// If you pass a plain object, it will be merged with the default values
15+
// (New in version 4)
16+
templateParameters: {
17+
'foo': 'bar'
2718
},
19+
// Or if you want full control, pass a function
20+
// templateParameters: (compilation, assets, assetTags, options) => {
21+
// return {
22+
// compilation,
23+
// webpackConfig: compilation.options,
24+
// htmlWebpackPlugin: {
25+
// tags: assetTags,
26+
// files: assets,
27+
// options
28+
// },
29+
// 'foo': 'bar'
30+
// };
31+
// },
2832
template: 'index.ejs'
2933
})
3034
]

0 commit comments

Comments
 (0)