Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there anyway to get raw svg? #132

Closed
shakiba opened this issue Jul 6, 2018 · 3 comments
Closed

Is there anyway to get raw svg? #132

shakiba opened this issue Jul 6, 2018 · 3 comments

Comments

@shakiba
Copy link

shakiba commented Jul 6, 2018

I use @svgr/webpack to load all .svg files and svg react components almost everywhere, except few places that I still need to use raw svg content. Is there anyway to get raw content of an imported svg file?

@gregberge
Copy link
Owner

I don't know what you mean by "raw SVG" but you can use SVGR + "url-loader" or SVGR + "file-loader". It is documented in README.

For most complex cases I suggest you to create two folders and duplicate SVG, one Webpack config for each folder.

@shakiba
Copy link
Author

shakiba commented Jul 11, 2018

What I mean is getting SVG content as string instead of a react component or url-encoded text. It would be great to be able to do something like this:

import StarIcon, { SvgSrting as starIconSvgString } from './star.svg'
// starIconSvgString == '<svg>...</svg>';

@gregberge
Copy link
Owner

You should try to put a raw-loader after svgr loader to convert it into a string before importing it.

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

No branches or pull requests

2 participants