Skip to content
This repository has been archived by the owner on Mar 18, 2023. It is now read-only.

Retrieve generated .svg file content in js #125

Open
rlebosse opened this issue Jan 30, 2017 · 1 comment
Open

Retrieve generated .svg file content in js #125

rlebosse opened this issue Jan 30, 2017 · 1 comment

Comments

@rlebosse
Copy link
Contributor

rlebosse commented Jan 30, 2017

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
Copy link

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>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants