简体   繁体   English

使用visual studio代码任务编译typescript,指定输出目录

[英]compile typescript with a visual studio code task, specifying the output directory

I have this task in visual studio code which compiles my typescript files. 我在visual studio代码中有这个任务,它编译我的打字稿文件。 I would like to make a cleaner file structure by adding all typescript to one folder and all javascript to another folder. 我想通过将所有typescript添加到一个文件夹并将所有javascript添加到另一个文件夹来创建更干净的文件结构。 How do I change the args of my task to do that? 如何更改任务的参数来执行此操作? My current code causes it to compile the output to be in the same folder as the typescript. 我当前的代码使它将输出编译为与typescript相同的文件夹。 Here is current code: 这是当前代码:

{
    "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"
}

I am not sure what is happening in your project. 我不确定你的项目中发生了什么。 But here is what I am using in my tsconfig.json used for my angular projects. 但这是我在用于角度项目的tsconfig.json中使用的内容。 You might want to use this as a sample for your project and modify accordingly. 您可能希望将其用作项目的示例并进行相应的修改。 outDir and outFile is what you need I guess. outDiroutFile就是你所需要的。

{
  "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" */

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM