如何使用Webpack组装HTML文档?

时间:2015-11-18 20:05:37

标签: html webpack

有没有办法用Web包装你的HTML,所以你有HTML块而不是大的HTML文件?

示例:

<html>
    <body>
        <div>Here is the main page </div>
        <script>
        // inject a chunk of HTML here
            require.include('./header.html');
        </script>
   </body>
</html>

我看到了HTML加载器,但我不认为我可以将它用于此目的。

1 个答案:

答案 0 :(得分:-2)

也许你需要这个html-loader

编辑:

您可以使用interpolate标志为ES6模板字符串启用插值语法,如下所示:

require("html?interpolate!./file.html");

<img src="${require(`./images/gallery.png`)}" />
<div>${require('./partials/gallery.html')}</div>