Retrieve generated .svg file content in js
Opened this issue · 1 comments
rlebosse commented
Instead of loading asynchronously the generated .svg file, is there a way to retrieve synchronously it's content in a js file in order to insert it in the webpage the way we want to ?
Something like this :
import svgStore from 'webpack-svgstore-plugin';
console.log(svgStore);
// <svg xmlns="http://www.w3.org/2000/svg" style="position:absolute; width: 0; height: 0"> ...
Thanks!
joaquimjmsilva commented
Hi,
I had the same need, so I did like this:
var __svg__ = { path: '../icons/*.svg', name: '[hash].icons.svg' };
// console.log(__svg__.filename); - Has the public path of the file, so you can use it for what you want.
// For example:
<svg>
<use xlink:href="<%=__svg__.filename %>#icon-<name>" />
</svg>