jantimon/html-webpack-plugin

How to reference asset modules within templateContent

jackmoore opened this issue · 1 comments

I'm using Webpack 5's asset modules (https://webpack.js.org/guides/asset-modules/) and I'm struggling to understand how they can be referenced inside of templateContent. For example, I'm using asset modules for some fonts and I'd like to be able to add preloads for those hashed URLs in templateContent. Can this be done?

Some years ago I built https://github.com/jantimon/resource-hints-webpack-plugin for this - However I am not sure if it works with asset-modules and hashes.

If you want to do it by yourself you might try something like <link rel="preload" href="<%= require('./path/to/asset.jpg') %>" as="image">