How to include html partials with webpack (version 2) with the html-loader?(如何在 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.
这篇关于如何在 html-loader 中包含带有 webpack(版本 2)的 html 部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 html-loader 中包含带有 webpack(版本 2)的 html 部分?


基础教程推荐
- 如何添加到目前为止的天数? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01