What is the official best method to import svg? #11399
-
I'm a newbie to sveltekit. I ask this question because importing svg is so simple in vite+svelte. However, I have not found a method of importing svg without the assistance of other external module. I also noticed that in vite, we have a public folder to store assets, and in sveltekit we didn't have it. Does anyone know a proper method for importing svg (and other static assets) in sveltekit? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
SvelteKit has a |
Beta Was this translation helpful? Give feedback.
-
Solution: don't import the image, just load it with img tag using the image filepath
|
Beta Was this translation helpful? Give feedback.
Actually, I don't understand, what you want. You say, that you want to load the SVG, but in your code example, you try to import it. Importing from static does not make sense, since importings are resolved on compile-time. So if you want to import the SVG, then you should place it in the $lib folder.
If you place the SVG in the static folder, you can load it from the browser with an img-Tag: