shift73k/assets_old/node_modules/svg-sprite-loader/examples/interop-with-html-webpack-plugin
2022-08-13 07:32:36 -04:00
..
build progress on migrating to heex templates and font-icons 2022-08-13 07:32:36 -04:00
main.js progress on migrating to heex templates and font-icons 2022-08-13 07:32:36 -04:00
README.md progress on migrating to heex templates and font-icons 2022-08-13 07:32:36 -04:00
template.ejs progress on migrating to heex templates and font-icons 2022-08-13 07:32:36 -04:00
webpack.config.js progress on migrating to heex templates and font-icons 2022-08-13 07:32:36 -04:00

HTML webpack plugin interop

When using html-webpack-plugin along with sprite-loader in extract mode it is possible to inline sprite content directly to the page. All extracted sprites stored in htmlWebpackPlugin.files.sprites template variable. It's an object where key is a sprite filename and value - file contents (Object<filename:string, content:string>).

Demo

Template example

...
<body>

<% if (htmlWebpackPlugin.files.sprites) { %>
  <% for (var spriteFileName in htmlWebpackPlugin.files.sprites) { %>
    <%= htmlWebpackPlugin.files.sprites[spriteFileName] %>
  <% } %>
<% } %>

</body>
...