HTML-的WebPack-插件与哈巴狗装载机不拾取选项
问题描述:
考虑:HTML-的WebPack-插件与哈巴狗装载机不拾取选项
plugins: [
new HtmlWebpackPlugin({
template: 'index.pug',
title: 'Page Title',
custom: 'Custom'
})
]
内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
我希望得到拾起自定义标题,但它输出取而代之的是Webpack App
(并且custom
变量是undefined
)。
- 的WebPack 1.15.0
- HTML-的WebPack-插件2.30.1
- 哈巴狗2.0.0 rc.4
我在束手无策就在这里,我感觉这是我错过的东西。
答
你有你的配置更改为:
plugins: [
new HtmlWebpackPlugin({
template: '!!pug-loader!index.pug',
title: 'Page Title',
custom: 'Custom'
})
]
+0
而且,我只是重新加载开发服务器,而不是监视器,所以我的配置更改根本没有被拾起......呃! – Ivan
+0
我对这个问题的建议是,当你有一个新的配置时,你应该使用一些文件监视器(nodemon,...)来重新加载。 – imcvampire
'htmlWebpackPlugin'选项只能在'.ejs'文件。 – imcvampire
@imcvampire认真吗?这是记录在哪里? – Ivan
它仅默认支持'ejs'。但你可以配置使用另一个加载器 – imcvampire