html-withimg-loader 会导致 webpack 的 templateParameters失效,不知道为何
在测试 templateParameters 的成员变量 在 template.html 中动态输出时
无意中试到 template.html 的 templateParameters 变量,经常是原文输出(即不能取得 templateParameters 的变量,如 title )
html-withimg-loader@0.1.16
排查一圈下来,发现 webpack对象 的 module 在包含 html-withimg-loader 的 rules ( loader ) 后,templateParameters 失效了,
查了下,这loader 是处理:
“html中直接使用img标签src加载图片的话,因为没有被依赖,图片将不会被打包。” https://github.com/wzsxyz/html-withimg-loader
的问题,不甚了解,且记下
比如:
//template.html: <%= title %>
//定义 webpackConfig:
module: {
rules: [
{
test: /.vue$/,
loader: 'vue-loader',
exclude: /node_modules/
},
// {//当包含插件,使 webpack.templateParameters 在模板中失效
// test: /\.html$/,
// loader: 'html-withimg-loader',
// },
]
}
//webpackConfig控件
webpackConfig.plugins.push(new HtmlWebpackPlugin({
templateParameters: {
'foo': 'bar',
title:'hello',
},
template: './template.html',
})
)
类似的问题, html-loader@0.5.5 和这个一样,
解决, https://www.jianshu.com/p/087a873d7784 介绍也可以通过
CopyWebpackPlugin
将资源复制到目标,
浙公网安备 33010602011771号