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

查看:482
本文介绍了如何使用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 **')}

我没有使用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 $ /,使用:['html-loader?interpolate']},是一个webpack配置规则通过指定 interpolate 标志来利用它。

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天全站免登陆