src
components
HomePage
Calendar.js
containers
HomePage
index.js
I'm just using the recommended folder structure in React(Presentation + Container). While I was working on react-boilerplate folder structure, I can refer Components inside components folder with out listing the relative path, import Calendar from 'components/HomePage/Calendar';
. How to do that in my project, without typing the full relative path, import Calendar from '../../components/HomePage/Calendar'
;
?
Create jsconfig.json or tsconfig.json depending on your project, javascript or typescript respectively.
Inside the json file.
My project snippet.
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"screens/*": ["src/screens/*"],
"components/*": ["src/components/*"],
"utils/*": ["src/utils/*"]
}
}
}
Like this way.
{
"compilerOptions": {
"baseUrl": "your top most parent folder",
}
}