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
中。