Can't use an image without src/assets/ at the path
I have a problem why can't I use images from the assets folder if there is no src/assets/image.png at the beginning of the path?
20 Replies
Can you show some relevant code that isn't working
Also are you using solid start?
nope
What are you using then? Just the base vite setup?
yes
assets is for internal things you import in code. public is for resources that are accessible directly in the front-end server
if you put your images inside of the public folder instead, it will be accessible from the
src
tag in an image, as a "regular" path.So I can just rename the assets folder to public?
a vite project, by default, will already contain a public folder
it's not inside the src folder
Vite
Next Generation Frontend Tooling
I don't have it
Create it
did you... delete it?
it's there by default, I assure you
It isn't in some of old solid templates
I've never made a vite project that didn't have this after using
npm create vite
ah yes maybe by using degit
which I believe isn't recommended anymoreI used degit
honestly you should probably just run
npm create vite@latest
, to get a better project structure to start with, and move your component code overthe project is too heavy and it would be better to stay on this structure
try to just create the public folder and see if it works
Yay, it's working!
:iara_cheer_yay: