有没有办法包含部分使用html-webpack-plugin? [英] Is there a way to include partial using html-webpack-plugin?
问题描述
我使用Webpack编译我的脚本和HTML(使用 html-webpack-plugin
)。问题是,我有5个包含相同部分的HTML文件,我想将这些部分分开以分开 .html
文件,然后
默认情况下,Webpack会为.js文件执行此操作,但可以我使用类似于HTML文件的东西?
您可以使用<%= require(' html!./ partial.html')%>
。示例: https:// github。 com / jantimon / html-webpack-plugin / blob / master / examples / custom-template / template.html
I am using Webpack to compile my scripts and HTML (using html-webpack-plugin
). The thing is, I have 5 HTML files that contains the same parts and I want to move these parts to separate .html
files and then include
these parts in every HTML file. This way, if I will change these smaller HTML files, it will recompile every HTML file to represent these changes.
Webpack does this for .js files by default, but can I use something like that for HTML files?
You can use <%= require('html!./partial.html') %>
in your template. Example here: https://github.com/jantimon/html-webpack-plugin/blob/master/examples/custom-template/template.html
这篇关于有没有办法包含部分使用html-webpack-plugin?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!