Javascript 使用visual studio代码任务编译typescript,并指定输出目录
我在VisualStudio代码中有这个任务,它编译我的typescript文件。我希望通过将所有typescript添加到一个文件夹,将所有javascript添加到另一个文件夹,从而使文件结构更清晰。如何更改任务的参数以实现此目的?我当前的代码使它将输出编译到与typescript相同的文件夹中。以下是当前代码:Javascript 使用visual studio代码任务编译typescript,并指定输出目录,javascript,typescript,visual-studio-code,Javascript,Typescript,Visual Studio Code,我在VisualStudio代码中有这个任务,它编译我的typescript文件。我希望通过将所有typescript添加到一个文件夹,将所有javascript添加到另一个文件夹,从而使文件结构更清晰。如何更改任务的参数以实现此目的?我当前的代码使它将输出编译到与typescript相同的文件夹中。以下是当前代码: { "version": "0.1.0", // The command is tsc. Assumes that tsc has been installed
{
"version": "0.1.0",
// The command is tsc. Assumes that tsc has been installed using npm install -g typescript
"command": "tsc",
// The command is a shell script
"isShellCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "silent",
// args is the HelloWorld program to compile.
"args": [
"scripts/front_end/view_models/search_filter_view_model.ts",
"scripts/front_end/models/area_getter.ts",
"scripts/front_end/bootstrap_app.ts",
"scripts/front_end/models/category.ts",
"scripts/front_end/plugins/slideshow.ts"
],
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
我不确定你的项目中发生了什么。但这里是我在用于角度项目的tsconfig.json中使用的内容。您可能希望将其用作项目的示例,并进行相应的修改
outDir
和outFile
是您所需要的
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false,
"outDir":"client/build/",
"outFile": "client/build/all.js",
"declaration": true
},
"exclude": [
"node_modules",
"server"
],
"include": [
"client/*.ts",
"client/**/*.ts",
"client/**/**/*.ts"
]
}
// Include all folders to put to a file.
/* "outDir":"client/build/",
"outFile": "client/build/all.js" */
谢谢outDir是js文件所在的目录吗?来自ts文件的所有js是否都放在一个文件中(client/build/all.js)?因此,您的js都在client/build/all.js中?
outDir
是所有js文件的构建所在的目录outFile
几乎相同,但区别在于它包含bundle(所有js文件)文件名。它包含从include
部分中提到的ts文件转换而来的所有js文件。tsconfig.json文件路径与前面提到的文件夹路径相对。所以在编译时要检查一下。