How can i access more simple to access any component?

Viewed 24

I have a bit complex structure, to access for a function inside of itemTypes i have to do this: import { ON_BOARDING_STEPS } from '../../../constants/itemTypes', i think this is too hard to read '../../../'

├── components
│   ├── App

│   ├── Editable
│   │   ├── formQuestion
              Editable.jsx
├── constants
│   └── itemTypes.js

i am using vite from reactjs

1 Answers

Create a jsconfig.json file on the project's root and add this code to it.

instead of '../../../constants/itemTypes' then you can write 'constants/itemTypes'

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "*": ["src/*"]
    }
  }
}
Related