You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can we omit the need to add ?react at the end of every SVG import?
Current situation
// worksexportdefaultdefineConfig({plugins: [react(),svgr()],// no paramsbase: `/${viteBaseName}/`,});importMyIconfrom"../MyIcon.svg?react";// has `?react`<MyIcon/>// works
Goal situation
I used the include option in vite.config.js, but that didn't work:
// this doesn't worksexportdefaultdefineConfig({plugins: [react(),svgr({include: "**/*.svg",// params}),],base: `/${viteBaseName}/`,});importMyIconfrom"../MyIcon.svg";// no `?react`<MyIcon/>// doesn't work/*DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('/vite-react-js-template/src/MyIcon.svg') is not a valid name*/
How to fix this? I think some default parameters may be missing in this second case. If yes, can we use callback pattern such the callback returns the default param, and I can selectively set include while retaining the rest.
The text was updated successfully, but these errors were encountered:
sanjarcode
changed the title
Include all SVG files, even without the ?react
Include all SVG files, without the ?react doesn't work
Jan 6, 2024
Can we omit the need to add
?react
at the end of every SVG import?Current situation
Goal situation
I used the include option in
vite.config.js
, but that didn't work:How to fix this? I think some default parameters may be missing in this second case. If yes, can we use callback pattern such the callback returns the default param, and I can selectively set
include
while retaining the rest.The text was updated successfully, but these errors were encountered: