Open barbalex opened 11 months ago
I was able to address the precise issue you were facing.
vite.config.ts
import TpopSvg100 from '../../Karte/layers/Tpop/statusGroupSymbols/100.svg'
=> You may enter in this way, and it will function.
Yes that works, as I wrote above (sorry for not being clear enough).
What I do not understand is why
import TpopSvg100 from '../../Karte/layers/Tpop/statusGroupSymbols/100.svg?react'
does not work.
Appending ?react seems to be the correct way to do it, so why can I do it sometimes but others it fails?
fwiw I was getting this same error because my import path was wrong and the svg didn't exist at the specified path
I am getting a similar error after upgrading. In addition, I'm also getting errors that the library tries to create tags using the full data URL of the SVG.
Example:
index-Kj62GyH0.js:102 DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M11.3088%207.20354L10.689%207.28414L10.7474%207.73284L11.1919%207.8175L11.3088%207.20354ZM10.9167%2011.3334V10.7084V11.3334ZM8.83333%2011.3334V11.9584V11.3334ZM5.78068%206.33335V6.95835H6.17571L6.34522%206.60154L5.78068%206.33335ZM13.625%209.25002C13.625%207.92783%2012.6782%206.82813%2011.4258%206.58958L11.1919%207.8175C11.8657%207.94585%2012.375%208.53913%2012.375%209.25002H13.625ZM10.9167%2011.9584C12.4124%2011.9584%2013.625%2010.7458%2013.625%209.25002H12.375C12.375%2010.0554%2011.7221%2010.7084%2010.9167%2010.7084V11.9584ZM8.83333%2011.9584L10.9167%2011.9584V10.7084L8.83333%2010.7084V11.9584ZM5.5%2011.9584H8.83333V10.7084H5.5V11.9584ZM2.375%208.83335C2.375%2010.5592%203.77411%2011.9584%205.5%2011.9584V10.7084C4.46447%2010.7084%203.625%209.86889%203.625%208.83335H2.375ZM5.5%205.70835C3.77411%205.70835%202.375%207.10746%202.375%208.83335H3.625C3.625%207.79782%204.46447%206.95835%205.5%206.95835V5.70835ZM5.78068%205.70835H5.5V6.95835H5.78068V5.70835ZM6.34522%206.60154C6.71371%205.82585%207.50343%205.29169%208.41667%205.29169V4.04169C7.00291%204.04169%205.78387%204.87007%205.21614%206.06517L6.34522%206.60154ZM8.41667%205.29169C9.58069%205.29169%2010.5429%206.16011%2010.689%207.28414L11.9286%207.12294C11.7025%205.38421%2010.2169%204.04169%208.41667%204.04169V5.29169Z'%20fill='currentColor'/%3e%3c/svg%3e') is not a valid name.
This blocks our adoption of Vite 5 as the major version 3 of vite-plugin-svgr
does not list it as a peerDependency.
I had the same error and solved it by removing a leftover declaration file from CRA were we handled svg's Hope it helps:
declare module "*.svg" {
const content: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
export default content;
}
I have had a lot of issues since upgrading to 4.0.0.
Some were solved by reverting the include pattern to what it was before (https://github.com/pd4d10/vite-plugin-svgr/issues/91#issuecomment-1732028802).
One only turned up as error in production (might have been a warning in dev):
Failed to execute 'createElement' on 'Document': The tag name provided ('/assets/101-021d24df.svg') is not a valid name.
. Not sure about this one, I am not looking forward to promoting the next version of my project to production.The one I am facing now in development is:
What baffles me is that this only happens in one file. Dozens of other files import svg without issues (in development...).
If I use
instead of
this does not happen.
I am not feeling good with the state of importing svg's using vite right now. Appending ?react in some imports but not in others just to circumvent weird errors seems way too hacky to me.
I am developing on Windows 11 which could influence casing issues.