如何在 html-loader 中包含带有 webpack(版本 2)的 html 部分? [英] How to include html partials with webpack (version 2) with the html-loader?

查看:35
本文介绍了如何在 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 部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆