I'm also using webpack to transpile and bundle onto public.
What are the pros and cons of keeping image assets in public vs non-public.
Which project structure is better for a react app?
public/
-images/
--favicon.ico
--(other-image-files...)
-index.html
-bundle.js
src/
-components/
-style/
-images/
-utils/
So for example if you use an image inside a component, it should be in the src folder but if you have an image outside the app (i.e. favicon) it should be in public.
Overall, the idea is that images in the public directory are accessible by URL outside your app. Anything in src will only be built in if you load it through webpack import.
The public folder contains static files such as index. html, javascript library files, images, and other assets, etc. which you don't want to be processed by webpack. Files in this folder are copied and pasted as they are directly into the build folder.
Overall, the idea is that images in the public directory are accessible by URL outside your app. Anything in src will only be built in if you load it through webpack import. I generally keep things in src unless it is publicly shared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With