expo-starter icon indicating copy to clipboard operation
expo-starter copied to clipboard

how to import assets

Open dragonlobster opened this issue 1 year ago • 0 comments

i couldn't figure out how to import assets in this project, what i ended up doing was:

  1. put my assets (like .pngs) in assets dir,
  2. added this to tsconfig.json
"paths": {
    ...,
    "@assets/*": [
        "assets/*"
    ]
}
  1. created a react-app-env.d.ts inside src dir:
declare module "*.png";
declare module "*.svg";
declare module "*.jpeg";
declare module "*.jpg";

and finally i could import my assets:

import examplePng from "@assets/example.png"

but i am wondering if i did too much work and there's another intended way to do this? i figured there might be something i missed in the starter project if this was taken into consideration, thanks!

dragonlobster avatar Feb 25 '24 03:02 dragonlobster