tsconfig.json
Nuxt 生成多個 TypeScript 配置檔案,其中包含合理的預設值和您的別名。
Nuxt自動生成多個 TypeScript 配置檔案(.nuxt/tsconfig.app.json
、.nuxt/tsconfig.server.json
、.nuxt/tsconfig.node.json
和 .nuxt/tsconfig.shared.json
),其中包含您在 Nuxt 專案中使用的已解析別名以及其他合理的預設值。
您可以透過在專案根目錄中建立包含以下內容的 tsconfig.json
檔案來利用此功能:
tsconfig.json
{
"files": [],
"references": [
{
"path": "./.nuxt/tsconfig.app.json"
},
{
"path": "./.nuxt/tsconfig.server.json"
},
{
"path": "./.nuxt/tsconfig.shared.json"
},
{
"path": "./.nuxt/tsconfig.node.json"
}
]
}
您可以根據需要自定義此檔案的內容。但是,建議您不要覆蓋
target
、module
和 moduleResolution
。如果您需要自定義
paths
,這會覆蓋自動生成的路徑別名。相反,我們建議您將所需的任何路徑別名新增到 nuxt.config
中的alias
屬性,它們將被自動拾取並新增到自動生成的 tsconfig
中。