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

How do you inline svgs? #85

Open
marcofugaro opened this issue Aug 9, 2023 · 5 comments
Open

How do you inline svgs? #85

marcofugaro opened this issue Aug 9, 2023 · 5 comments

Comments

@marcofugaro
Copy link

The advantage of using svgr is that it inlines the .svg files in the react code. Any way to do this with vite-plugin-svgr?

Currently even the small files are not included:
image

@nice-wwming
Copy link

I also want to solve this problem because there are too many svg in the project, and the size of the picture is very small but it will take up the http request. I hope the author can provide an inline solution.

@mattsputnikdigital
Copy link

I believe they are inlined but vite also emits them into the build folder. Are you seeing them being requested?

@marcofugaro
Copy link
Author

@mattsputnikdigital yeah you're right, I don't see the HTTP requests to the .svg files, looks like they are actually inlined for me.

@mattsputnikdigital
Copy link

@mattsputnikdigital yeah you're right, I don't see the HTTP requests to the .svg files, looks like they are actually inlined for me.

Yes this is an issue I have been trying to resolve. It is easy enough to use noEmit to not let the build include SVG files, but that is all SVG files, not just the ones used as React Components, ones used as background images etc...

I think the plugin needs a bit of an update to support this behaviour.

Im struggling to find the webpack setting in CRA which would do the same thing.

@pd4d10
Copy link
Owner

pd4d10 commented Sep 20, 2023

See #71 (comment)

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

4 participants