我目前正在使用 create-react-app
来引导我的一个项目。基本上,我试图通过将这些添加到由 create-react-app 生成的默认 tsconfig.json 中来设置 tsconfig.json 中的路径:
"baseUrl": "./src",
"paths": {
"interfaces/*": [
"common/interfaces/*",
],
"components/*": [
"common/components/*",
],
},
但是,每次我运行 yarn start
基本上运行 react-scripts start
时,它都会删除我的更改并再次生成默认配置。
如何告诉 create-react-app 使用我的自定义配置?
原文由 CodeIntern 发布,翻译遵循 CC BY-SA 4.0 许可协议
我能够通过使用来自 这个问题 的建议来做到这一点。
将 React 脚本喜欢删除的配置选项放在一个单独的文件中(例如 paths.json),并通过 extends 指令从 tsconfig.json 中引用它。
路径.json:
tsconfig.json文件