Open Bonjour123 opened 4 months ago
Understood. The vite asset loader loads an asset by default exporting the url. And svgr doesn't support enforcing the default export. see here.
This line should be if (opts.exportType!=="default" && (opts.state.caller?.previousExport || opts.exportType === 'named')) {
Or maybe it's by design, but right now I can't see any justification for this.
If it's by design and won't be fixed, then those who want the default export feature can:
cd ./packages/rollup
pnpm link --global
pnpm link --global @svgr/rollup
Then to replace all the named imports to default imports, you can use this regexp:
pattern: import \{ReactComponent as ([^}]*)}
replace: import $1
🐛 Bug Report
exportType doesn't seems to be supported. 3 years ago I was using webpack it wasn't supported, 3 years later, I use vite (and so rollup.js) and exportType still isn't supported.
To Reproduce
Expected behavior
I expect to get a the component as default export, so that I'm not forced to use the long boilerplate
"import {ReactComponent as My_svg} ...