An Interest In:
Web News this Week
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
March 26, 2022 05:31 am GMT
Original Link: https://dev.to/ashirbadgudu/absolute-import-in-create-react-app-10ga
Absolute import in create-react-app
Want to get rid of the annoying, long, boring import statements in react?
import {Card} from './../../components/Card';
Just create a jsconfig.json
file in your projects root directory and the following code
{ "compilerOptions": { "baseUrl": "src" }, "include": ["src"]}
Yaa it is that much simple to do now you can go into your file and replace the previous code with
import {Card} from 'components/Card';
Make sure you restart the server after creating the
jsconfig.json
file
Now do you want create
jsconfig.json
file all of your projects in more efficient way?Then Open up your project root directory in the terminal and run
npx react-jsconfig
It will automatically generate the
jsconfig.json
file for you
Original Link: https://dev.to/ashirbadgudu/absolute-import-in-create-react-app-10ga
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To