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
Migrating from react-scripts to Vite I need the URL for the imported SVG file. But I cannot figure out how to expose the URL rather than the React component with vite-plugin-svgr 4 (to use e.g. when you want to use the SVG as a background image).
In my old react-scripts setup I could do something like this: import actionActivityIconUrl { ReactComponent as ActionActivityIcon } from './@img/action/activity.svg';
so I could use both the generated URL and the generated react component. But this version of vite-plugin-svgr is supposed to be used like this: import ActionActivityIcon from './@img/action/activity.svg';
but how do I get the URL?
And where is the reference documentation for vite-plugin-svgr? I can only find simple examples in the readme file here but cannot find all possible options for how to use vite-plugin-svgr.
The text was updated successfully, but these errors were encountered:
I was expecting url to be returned when pattern ?react was not present. This is a blocker for us
@swedieman It turned out that it was actually a vite change related to assets that caused our problems. Disabling inlining solved problem for now. I guess we need to dig deeper and see, if we actually want to conditionally enable this. While vite should also support ?url suffix that got inlined too :-(
For react component: from './@img/action/activity.svg?react'
For url: from './@img/action/activity.svg?url' or from './@img/action/activity.svg' (inlining must be disabled)
export default defineConfig({
build: {
assetsInlineLimit: 0, // disables inlining - supports also a matcher function
Would you like to use style { ReactComponent as ActionActivityIcon } configure plugin with this:
Migrating from react-scripts to Vite I need the URL for the imported SVG file. But I cannot figure out how to expose the URL rather than the React component with vite-plugin-svgr 4 (to use e.g. when you want to use the SVG as a background image).
In my old react-scripts setup I could do something like this:
import actionActivityIconUrl { ReactComponent as ActionActivityIcon } from './@img/action/activity.svg';
so I could use both the generated URL and the generated react component. But this version of vite-plugin-svgr is supposed to be used like this:
import ActionActivityIcon from './@img/action/activity.svg';
but how do I get the URL?
And where is the reference documentation for vite-plugin-svgr? I can only find simple examples in the readme file here but cannot find all possible options for how to use vite-plugin-svgr.
The text was updated successfully, but these errors were encountered: