簡體   English   中英

使用默認快捷方式運行多個任務

[英]Run more than one task with default shortcut

在一個項目中,我使用打字稿為服務器端(node.js)生成es6,為客戶端生成es5。 我有一個tsconfig.json和一個tsconfigclient.json。 我在task.json中有兩個任務來生成javascript:

 { "version": "2.0.0", "tasks": [ { "type": "typescript", "tsconfig": "tsconfig.json", "problemMatcher": [ "$tsc" ], "group": { "kind": "build", "isDefault": true } }, { "type": "typescript", "tsconfig": "tsconfigclient.json", "problemMatcher": [ "$tsc" ], "group": { "kind": "build", "isDefault": true } } ] } 

兩者都可以通過ctrl-shift-B來運行...但是vscode問我一個要使用嗎? 是否可以使用ctrl-shift-b同時啟動兩者

謝謝。 PS:我是node.js,打字稿和vscode的初學者。

一種選擇是創建一個復合任務,該任務使用dependsOn來運行其他兩個任務:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build1",
            "identifier": "build1",         
            "type": "typescript",
            "tsconfig": "tsconfig.json",
            "problemMatcher": [
                "$tsc"
            ],
            "group": "build"
        },
        {
            "label": "build2",
            "identifier": "build2",
            "type": "typescript",
            "tsconfig": "tsconfigclient.json",
            "problemMatcher": [
                "$tsc"
            ],
            "group": "build"
        },
        {
            "label": "Composite",
            "dependsOn": [
                "build1",
                "build2"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }

        }
    ]
}

您還可以使用命令行任務來運行多個命令。 此答案有關於此的更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM