Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to include partial using html-webpack-plugin?

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?

like image 367
serge1peshcoff Avatar asked Feb 12 '17 21:02

serge1peshcoff


People also ask

How does HTML webpack plugin work?

The HtmlWebpackPlugin simplifies creation of HTML files to serve your webpack bundles. This is especially useful for webpack bundles that include a hash in the filename which changes every compilation.


1 Answers

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

like image 59
display name Avatar answered Sep 20 '22 10:09

display name