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 to dynamically introduce it after version 4.0 #90
Comments
I am also getting unexpected behaviour when trying to dynamically import. The import returns a path string instead of a React component. I was playing with a stack blitz from this article that was demoing how to work with vite/svgr and dynamic imports. It references an outdated version of this plugin so I forked the dynamic import stack blitz and updated all the packages. As you can see in this minimal repro the plugin appears to be returning a path string to the component instead of a React component which causes React to blow up. |
I'm also having errors since version 4. My test with vitest returns this error on all my tests that contains a component SVG :
No problem on version 3. |
Same issue here. Dynamic imports do not work as described by @alexbaulch |
It seems caused by the Is this kind of usage working at v3.0? |
@pd4d10 Yes, it's working before Regarding @trungpham71198 's solution, I can't take it since I sometimes still use the normal This critical is preventing me from upgrading to Vite 5, since it's only supported in Please have a look into it, cheers. 💚 |
Just to add my 2 cents it' no solutions seems to work in vitev5 like here https://stackblitz.com/edit/vitejs-vite-fz5lgu?file=src%2FSvgIcon.tsx,package.json |
Still a work-around, but if you still want to import normal svg's you can change the file name of svg's you do want to be picked up by svgr and change the
In vite config: svgr({
include: '**/*.svgr.svg'
}) Then your import should also append await import(`path/to/${iconName}.svgr.svg`) |
Any official fix on this please? @pd4d10 |
This issue is preventing me from upgrading to Vite5 😭 |
Same issue for me, can't dynamically import SVGs after upgrading to version 4 :( |
Any updates? |
Thanks for your advice. For me it worked partially. So, I went to
This works for me. |
How to dynamically introduce it after version 4.0?
The text was updated successfully, but these errors were encountered: