travel/admin/node_modules/svg-sprite-loader/examples/interop-with-html-webpack-p...
yaosen 242417d45d init... 2024-06-24 11:28:18 +08:00
..
build init... 2024-06-24 11:28:18 +08:00
README.md init... 2024-06-24 11:28:18 +08:00
main.js init... 2024-06-24 11:28:18 +08:00
template.ejs init... 2024-06-24 11:28:18 +08:00
webpack.config.js init... 2024-06-24 11:28:18 +08:00

README.md

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>
...