我们使用第三方库 @craco/craco 配置别名
教程
安装 @craco/craco
1
npm i -D @craco/craco
在项目根目录下创建配置文件
path.tsconfig.json
:1
2
3
4
5
6
7
8
9
10{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": [
"src/*"
]
}
}
}修改 package.json 中的脚本命令
1
2
3
4
5
6"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "craco eject"
},在根目录中配置 tsconfig.json:
1
2
3
4
5
6
7
8
9
10
11{
"extends": "./path.tsconfig.json",
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
}
}yarn start 重启项目即可。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 白雾茫茫丶!
评论
您无需删除空行,直接评论以获取最佳展示效果