Consider:
plugins: [
new HtmlWebpackPlugin({
template: 'index.pug',
title: 'Page Title',
custom: 'Custom'
})
]
Inside index.pug
:
doctype html
html
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible" content="IE=edge")
meta(name="viewport" content="width=device-width, initial-scale=1")
title= htmlWebpackPlugin.options.title
I would expect the custom title to get picked up, but it outputs the default Webpack App
instead (and the custom
variable is undefined
).
I'm at my wits' end here, and I get the feeling it's something obvious I missed.
You have to change your config to:
plugins: [
new HtmlWebpackPlugin({
template: '!!pug-loader!index.pug',
title: 'Page Title',
custom: 'Custom'
})
]
Read more about this https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md#2-setting-a-loader-directly-for-the-template