How to configure react-script so that it doesn't override tsconfig.json on 'start'

前端 未结 5 1751
离开以前
离开以前 2020-12-08 18:58

I\'m currently using create-react-app to bootstrap one of my projects. Basically, I\'m trying to set up paths in tsconfig.json by adding these to the default ts

5条回答
  •  一整个雨季
    2020-12-08 19:28

    Create React App does not currently support baseUrl. However there is a workaround...to setup baseUrl for both webpack and the IDE you have to do the following:

    1. Create a .env file with the following code:
    NODE_PATH=./
    
    1. Create a tsconfig.paths.json file with the following code inside:
    {
      "compilerOptions": {
        "baseUrl": "src",
        "paths": {
          "src/*": ["*"]
        }
      }
    }
    
    1. Add the following line to tsconfig.json
    {
      "extends": "./tsconfig.paths.json",
      ...
    }
    

提交回复
热议问题