Antediluvian
Antediluvian

Reputation: 713

how to set up a constant import root path?

I have a big project with lots of folders:

...
|
--- components
| |
| --- c1
| | |
| | --- c11
| --- c2
--- models
| |
| --- m1
--- services
  |
  --- s1

eg in c11, how i currently import m1 is to use ../../models/m1. But this is dreadful because in the future if the folder structure changes, I have to change the relative path too. What I want is something like my-models/m1 where my-models is defined somewhere in some way. And if there is a future change, I only need to change its definition instead of each individual importing module.

Can anyone please give me some suggestions on this?

Upvotes: 0

Views: 103

Answers (1)

MNN TNK
MNN TNK

Reputation: 372

this medium article will solve your problems :

Absolute imports with React

Upvotes: 1

Related Questions