Closed cslettengren closed 2 years ago
Also having this issue
Hi, I've tested it but it still works for me. Could you create a Code Sandbox to illustrate the problem?
It is only broken when you try running the built javascript files, which makes sense since this is what changed in version 3.3.0:
const isRootRef = viteConfig.command === 'build' && !id.startsWith(viteConfig.root)
if (!id.match(svgRegex) || isRootRef) {
return
}
In my case I guess isRootRef will be true and that's why it's returning before even considering what kind of import it should be.
Just wanted to confirm that I was running into this in my production builds (even though dev worked perfectly) and updating the vite-svg-loader
version to 3.2.x
fixed it for me.
It is only broken when you try running the built javascript files, which makes sense since this is what changed in version 3.3.0:
const isRootRef = viteConfig.command === 'build' && !id.startsWith(viteConfig.root)
if (!id.match(svgRegex) || isRootRef) {
return
}
In my case I guess isRootRef will be true and that's why it's returning before even considering what kind of import it should be.
@cslettengren thanks for your clarification. Now the trick is to figure out why isRootRef
becomes true. Could you share your alias configuration in vite.config.js
?
I've removed the isRootRef check in v3.4.0. So this should be fixed!
import myIcon from '@assets/myIcon.svg?component';
is importing the icon as a url string since version 3.3.0