0

现在我们在 Visual Studio Code 中使用 tasks.json 0.1.0 版本的任务。

导航到https://code.visualstudio.com/docs/editor/tasks表明 VS 代码将自动检测我的 gulp 文件中的所有任务。

我已经安装了各种扩展来尝试自动检测我的任务,但它们仍然没有被检测到。

在这一点上,我正在考虑创建一个新版本的 tasks.json 来处理我们所有的 gulp 任务。

我该怎么做呢?这是我的tasks.json 0.1.0:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [],
"showOutput": "always",
"options": {
    "cwd": "${workspaceRoot}/MyAppName"
},
"tasks": [
    {
        "taskName": "build",
        "args": ["build:debug"]
    },
    {
        "taskName": "build:debug",
        "args": ["build:debug"]
    },
    {
        "taskName": "build:release",
        "args": ["build:release"]
    }
]
}

我查看了其他问题,目前似乎没有任何内容表明如何在 tasks.json 2.0 中运行 gulp。

我希望能够从包含 gulpfile 的文件夹之外使用此构建任务。我知道如果打开了我的 gulpfile 的文件夹,VS 会自动检测任务。

4

1 回答 1

0

在网上搜索后,我找不到任何东西。我想为我们的 build:debug gulp 任务设置一个自定义构建代码。

所以,我建立了自己的:

(buildDebug.sh)

#!/bin/bash
clear
pwd
cd [your gulpfile.js directory]
gulp build:debug

(任务.json)

    {
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "Run Build",
            "type": "shell",
            "command": "/c/[where you saved buildDebug.sh]/buildDebug.sh",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal": "always",
                "panel": "shared"
            }
        }
    ]
}
于 2017-09-06T20:21:11.693 回答