SVGR adds svg code to .js when bundled with webpack 5 #804
Unanswered
chetankondawle
asked this question in
Q&A
Replies: 1 comment
-
You can't. The idea os SVGR is to bundle SVG in .js files. Read this article to better understand this issue: https://kurtextrem.de/posts/svg-in-js?ref=news.typeofweb.com |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have component library which contains multiple svgs which is built using SVGR. This component library is being consumed by my-app. When my-app is bundled with webpack 5 it creates .js file for this component library and it has the svg code in it, there by increasing .js file size in final bundle.
Component Library Config
my-app Webpack Config
Svg file is consumed as a react component like this.
In final bundle svg code is added in the .js file and seperate .svg file is also loaded.
How to avoid svg code from being included in .js file?
Beta Was this translation helpful? Give feedback.
All reactions