项目目录外部的tsconfig.json文件

问题描述

我有一个项目portal。在开发过程中,我意识到我实际上需要在存储库中进行多个项目。因此,我现在有一个像这样的项目结构:

enter image description here

我想知道,是否可能在tsconfig.jsonportal目录之外都包含shop文件,这意味着打字稿编译器选项将适用于两个项目吗?在门户项目上执行npm run serve时,似乎出现了此错误

Error: Cannot find "C:\Git\ui\portal\tsconfig.json" file. Please check webpack and ForkTsCheckerWebpackPlugin configuration. 
Possible errors: 
  - wrong `context` directory in webpack configuration (if `tsconfig` is not set or is a relative path in fork plugin configuration)
  - wrong `tsconfig` path in fork plugin configuration (should be a relative or absolute path)

我不太确定它的来源,因为我的代码库中没有定义这样的文件路径。

tsconfig.json内容是:

{
 "compilerOptions": {
"target": "ES2020","module": "ESNext","strict": true,"jsx": "preserve","importHelpers": true,"moduleResolution": "node","experimentalDecorators": true,"allowJs": true,"esModuleInterop": true,"allowSyntheticDefaultImports": true,"sourceMap": true,"baseUrl": "portal","types": [
  "webpack-env"
],"paths": {
  "@/*": [
    "src/*"
  ]
},"lib": [
  "esnext","dom","dom.iterable","scripthost"
]
 },"include": [
  "portal/src/**/*.ts","portal/src/**/*.tsx","portal/src/**/*.vue"
 ],"exclude": [
 "node_modules"
 ]
}

解决方法

尝试以下操作:保留现有的tsconfig.json,然后在每个文件夹中创建一个包含以下内容的tsconfig.json

{
    "extends": "../tsconfig.json"
}