絶対的なインポートを作成


したいのは、迷惑な、長い、退屈なインポートステートメントを取り消すには?
import {Card} from './../../components/Card';
ジャストクリエイトjsconfig.json プロジェクトのルートディレクトリと次のコードのファイル
{
    "compilerOptions": { "baseUrl": "src" },
    "include": ["src"]
}  
Yaaそれはあなたのファイルに行くことができますし、以前のコードを置き換えることができます今は非常に簡単です
import {Card} from 'components/Card';

Make sure you restart the server after creating the jsconfig.json file

  • 今すぐ作成しますかjsconfig.json ファイルのすべてのプロジェクトのより効率的な方法で?
  • 次に、プロジェクトルートディレクトリをターミナルに開き、実行します
  • npx react-jsconfig
    

    It will automatically generate the jsconfig.json file for you


    Learn More About react-jsconfig