Paths config Imports can have very nested relative paths Like ../../../../file.js We can make a shortcuts to folders and make paths absolute It will be easier to move files around the project jsconfig.json https://create-react-app.dev/docs/importing-a-component/#absolute-imports
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
Component at srs/components/Button.js can be imported from anywhere With following import Button from 'components/Button' Alias In typescript projects we can even make aliases to folders
{
"compilerOptions": {
"target": "es6",
"baseUrl": ".",
"paths": {
"@root/*": ["/*"],
"@src/*": ["src/*"],
"@components/*": ["src/components/*"],
"@store/*": ["src/store/*"],
"@utils/*": ["src/utils/*"],
}
}
}
At js file
import { theme } from '@src/theme'