HTMLWebpackPlugin from npm using custom template with .headTags is empty

  html-webpack-plugin, javascript, webpack

I want to set the options to inject: false and use <%= htmlWebpackPlugin.tags.headTags %> to put the generated tags in a place of my choosing in the template I am using as a file.

I have multiple entry points in webpack and each entry point needs to be output as its own <entryName>Partial.html to actually navigate to in the browser.

I thought <%= htmlWebpackPlugin.tags.headTags %> would work to included the depended files imported for the relevant entry and it would sub it out in my template but it is empty. The following, however, DOES WORK:

<% for (var chunk in htmlWebpackPlugin.files.js) { %><script src="<%= htmlWebpackPlugin.files.js[chunk]%>"></script><% } %>

I dont see much documentation on htmlWebpackPlugin.files. so I’m scared I might miss out on some other files if I dont use something more generic like the proposed .headTags that isnt working for me. i.e. like css files or anything else that might be there

Source: Ask Javascript Questions

LEAVE A COMMENT