如何在 html-loader 中包含带有 webpack(版本 2)的 html 部分?
我正在努力通过 html-loader 包含一个简单的 footer.html,作为 html 部分).我正在使用 webpack 版本 2.
I am working hard to include a simple footer.html, as an html partial) via html-loader. I am using webpack version 2.
我未能尝试使用 ${require('**./footer.html**')} 和 ${require('**../footer.html**')}.
I failed trying to use ${require('**./footer.html**')} and ${require('**../footer.html**')}.
我没有使用 ejs 加载程序,也没有使用车把插件.
I am not using ejs loader and I do not use the handlebar plugin.
有人知道我该如何解决这个问题,以及是否可以使用 webpack 渲染部分内容.
Does somebody know how I can fix this problem and whether it possible to render partials with webpack.
感谢您的建议!
推荐答案
这个特性叫做 插值.这里 { test:/.html$/, use: ['html-loader?interpolate'] }, 是一个 webpack 配置 rule,它通过指定 <代码>插值标志.
The feature is called interpolation. Here { test: /.html$/, use: ['html-loader?interpolate'] }, is a webpack configuration rule that leverages it by specifying the interpolate flag.
相关文章