importing static assets (telling vinxi/vite about stuff other then png's)
Every other month, I feel like i'm facing this again.
How to import static assets in solidjs?
The docs https://docs.solidjs.com/solid-start/building-your-application/static-assets say:
Vite provides a way to import assets directly into your Solid components:If I try the same with other stuff like
*.svg or *.txt the import fails.
I did have a an older solidjs project where I could do
In the old project I did this via
Is there a way we can still do this with solidjs/start? Since we don't have a vite.config anymore?9 Replies
For .txt try adding ?raw to the path
For the svg plugin add it to
vite.plugins in your configthank you for reminding me of
?raw, it doesn't seem to work though
It should work at runtime, you might need to add your own types
ah, it seems it may work after all, just typescript throwing errors
I see
the
solidSvg you would put in the vite section of
?Yeah
I put all my static files in the public/ folder and reference them using absolut paths (folder = public/imgs/img.png, link = /imgs/img.png).
I wonder if it is better or worse vs using the static import feature from vite?
yeah, I used to do most imports via vite but now I'm also mostly using the public folder..
Hey there 👋 How did you solve this yet ? May I know ? I'm facing the issue that if i use vite-plugin-solid-svg my app breaks with

try with the above comment on
?raw maybe that works
typescript will still complain but in my build it worked