【发布时间】:2019-06-23 18:00:39
【问题描述】:
当我分别使用ejs-loader 和html-loader 时一切正常:
<body>
<%= require('./header.html')({x:1}) %>
</body>
// compiles to:
<body>
<header><div>1</div></header>
</body>
但是当我链接它们时,我得到的是 js 代码而不是 html:
module.exports = function (obj) {
obj || (obj = {});
var __t, __p = '';
with (obj) {
__p += '\n<body>\n ' +
((__t = ( require('./header.html')({x:1}) )) == null ? '' : __t) +
'\n</body>';
}
return __p
}
发生了什么,我该如何解决?
这是我的配置:
const config = {
//...
module: {
rules: [
{
test: /\.html$/,
use: ['html-loader', 'ejs-loader']
}
]
},
//...
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html',
})
]
}
【问题讨论】:
-
你修好了吗?
标签: webpack