Skip to content

Instantly share code, notes, and snippets.

@faisalahammad
Last active February 28, 2022 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faisalahammad/c683fc242914171b0641af451e007b20 to your computer and use it in GitHub Desktop.
Save faisalahammad/c683fc242914171b0641af451e007b20 to your computer and use it in GitHub Desktop.

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:

  1. Create a public folder in root directory.
  2. Create sub-folder for assets.
  3. 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment