Skip to content

how to import assets #48

@dragonlobster

Description

@dragonlobster

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions