If you're using Vite⚡️then you might be face hard time to located your assets. Because it's not working like create-react-app (CRA)
. So if you located your file inside sub-folder of src
, it'll not include on build process.
Here is the solution:
- Create a
public
folder in root directory. - Create sub-folder for assets.
- Import images from public/images/ like this way
const errorImg = new URL("/images/404-page.jpg", import.meta.url);
. So you've to start with/folder/asset.ext
then it'll be included in the build process.