vue项目中 jsconfig.json和tsconfig.json文件配置释义 & compilerOptions配置
warning:
这篇文章距离上次修改已过469天,其中的内容可能已经有所变动。
jsconfig.json 和 tsconfig.json 是配置文件,分别用于 JavaScript 和 TypeScript 项目,它们包含有关编译器选项的信息。
jsconfig.json
include:指定哪些文件应该被加入到编译过程中。exclude:指定哪些文件应该被排除在编译过程外。compilerOptions:这是一个重要部分,包含大量影响编译器行为的选项。
tsconfig.json
compilerOptions:同样包含大量影响编译器行为的选项。include和exclude:同jsconfig.json。files:指定一个文件列表,这些文件将被包含进项目中。extends:允许一个配置文件继承另一个配置文件。references:允许一个项目根据不同的路径引用其他项目。
compilerOptions
target:设置编译目标的ECMAScript版本。module:指定生成代码的模块系统。strict:开启所有严格的类型检查选项。baseUrl:设置解析非相对模块名的基路径。paths:设置模块名到路径的映射。outDir:指定输出文件的目录。rootDir:指定编译器应该从哪个目录开始查找文件。lib:指定一个或多个要包含在编译中的库文件。
示例
jsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"strict": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}tsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}这些配置文件设置了项目的根目录(通过baseUrl和paths),指定了项目包含的文件(通过include),排除了不参与编译的文件(通过exclude)。对于TypeScript项目,还启用了一些编译选项,如装饰器支持和ES模块互操作性。
评论已关闭