Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to import assets #48

Open
dragonlobster opened this issue Feb 25, 2024 · 0 comments
Open

how to import assets #48

dragonlobster opened this issue Feb 25, 2024 · 0 comments

Comments

@dragonlobster
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant