-
Go to project's root directory.
-
Create tsconfig.paths.json
.
-
Edit it as follows:
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@file-alias": ["./your/file.tsx"],
"@folder-alias/*": ["./very/long/path/*", "./very/long/path/"]
}
}
}
-
Go to tsconfig.json
.
-
Add the following line to the beginning of the file:
{
+ "extends": "./tsconfig.paths.json",
"compilerOptions": {
"target": "es5",
...
},
...
}
-
Go to package.json
.
-
Replace react-scripts
with cra-alias
, like that:
"scripts": {
- "start": "react-scripts start",
+ "start": "cra-alias start",
- "build": "react-scripts build",
+ "build": "cra-alias build",
- "test": "react-scripts test",
+ "test": "cra-alias test",
"eject": "react-scripts eject"
}