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
Raqueebuddin Aziz
Can you show some relevant code that isn't working Also are you using solid start?
Дикий
Дикий9mo ago
<img src='/smiles/1.png' alt='12'} />
<img src='/smiles/1.png' alt='12'} />
nope
Raqueebuddin Aziz
What are you using then? Just the base vite setup?
Дикий
Дикий9mo ago
yes
<Alterion.Dev>
<Alterion.Dev>9mo ago
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.
Дикий
Дикий9mo ago
So I can just rename the assets folder to public?
<Alterion.Dev>
<Alterion.Dev>9mo ago
a vite project, by default, will already contain a public folder it's not inside the src folder
Дикий
Дикий9mo ago
I don't have it
Raqueebuddin Aziz
Create it
<Alterion.Dev>
<Alterion.Dev>9mo ago
did you... delete it?
<Alterion.Dev>
<Alterion.Dev>9mo ago
it's there by default, I assure you
No description
Raqueebuddin Aziz
It isn't in some of old solid templates
<Alterion.Dev>
<Alterion.Dev>9mo ago
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 anymore
Дикий
Дикий9mo ago
I used degit
<Alterion.Dev>
<Alterion.Dev>9mo ago
honestly you should probably just run npm create vite@latest , to get a better project structure to start with, and move your component code over
Дикий
Дикий9mo ago
the project is too heavy and it would be better to stay on this structure
<Alterion.Dev>
<Alterion.Dev>9mo ago
try to just create the public folder and see if it works
Дикий
Дикий9mo ago
Yay, it's working!
<Alterion.Dev>
<Alterion.Dev>9mo ago
:iara_cheer_yay:
Want results from more Discord servers?
Add your server