VITE + REACT folder structure "public" vs "src/assets"?

As the title says I am looking for the best practice where should I store my static content eg.: png, font, svg, favico. Public (Vite assets folder): you can reference the static files by this folder location without the need of "public" to be spcified. src/assets (react assets folder): It is bundled together with other react files (a bit smaller size), also you can refer it as a module.
7 Replies
Coder_Carl
Coder_Carl•10mo ago
I follow the convention that is specified in their docs (depending on which library/ framework I am using) it makes sure Im not fighting something for no reason
vince
vince•10mo ago
In Astro I believe src/assets is for when you want to modify the image programatically in some way, whereas in public you leave it as-is
Erik
Erik•10mo ago
I spent hours to read not just the official docs but reddit, properly feeded AI and some youtube videos. Their official statement is contradictory. Vite suggests public folder as static assets folder, like wwwroot in dotNET. React follows the same with it's own assets folder:D I have chosen the public folder since the outer scope context is Vite not React standalone but I am still unsure.
Coder_Carl
Coder_Carl•10mo ago
so one of those 2 things will end up building your app. use that one.
Erik
Erik•10mo ago
Okey, thanks 🙂
vince
vince•10mo ago
I think that makes sense! As long as you have a logical reason and it builds I think you're good 🙂
Erik
Erik•10mo ago
I just checked and we have Vite plugins for image manipulation, optimisation etc... so it's also similar or even more If I take this into consideration. https://github.com/ElMassimo/vite-plugin-image-presets Thanks for your answer Vince 🙂
Want results from more Discord servers?
Add your server