webpack如何在HTML页面中使用include?

查看:389
本文介绍了webpack如何在HTML页面中使用include?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

比如index.html

<!DOCTYPE html>
<html lang="en">

<incloud> './head.html' </incloud>

<body>
    <h1>index</h1>
</body>

<incloud> './footer.html' </incloud>

</html>

生成出来之后是

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <h1>index</h1>
</body>
</html>

html-loader貌似不能做到这种

解决方案

The best integration with webpack and your index.html file, would be html-webpack-plugin.

Not only does it inject css/javascript bundles into a templated html file. But it also gives you fine-grained control.

If you are trying to use multiple templates and include them into eachother, then you may want to look into a different templating language like Pug/Jade or Handlebars. (Each of these have specific webpack loaders for their respective types).

这篇关于webpack如何在HTML页面中使用include?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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