Gulpfile无法识别

时间:2015-05-01 18:37:37

标签: gulp visual-studio-code

文档说明应该自动检测gulp和jake文件。我在打开的文件夹的根目录中有一个gulpfile.js,但是当我尝试运行任务时,它没有被自动检测并列在任务列表中。我错过了什么吗?

4 个答案:

答案 0 :(得分:7)

    根目录中
  1. gulpfile.js

  2. npm install -g gulp:gulp全球安装

  3. npm install gulp:gulp在本地安装到您的开发文件夹

  4. 您需要自定义tasks.json文件:

    {
        "version": "0.1.0",
        "command": "gulp",
        "isShellCommand": true,
        "args": [
            "--no-color"
        ],
        "tasks": []
    }
    

答案 1 :(得分:1)

感谢miked指向正确的方向。以下是VSCode今天的工作原理:

如果tasks.json文件存在并且它定义了没有自动检测支持的任务运行器(例如命令属性)(例如tsc),则tasks.json优先于自动检测。

如果它列出了一个具有自动检测功能的命令(例如gulp和jake),那么它会将tasks.json中定义的任务与自动检测到的任务合并。

通常,VSCode现在只支持一个任务运行器集成。因此,如果您同时使用gulp和grunt,VSCode可以立即与Grunt或Gulp集成。

答案 2 :(得分:1)

Visual Studio Code with(tasks.json - version 2.0.0)。包括gulp任务跑步者。 “Ctrl + Shift + B” - >在gulpfile.js中执行任务 - >使用Chrome浏览器打开html文件。

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "taskName": "Gulp",
        "type": "shell",
        "command": "gulp",
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "presentation": {
            "reveal": "always"
        }
    },
    {
        "taskName": "Chrome",
        "type": "process",
        "command": "chrome.exe",
        "windows": {
            "command": "C:\\Program Files(x86)\\Google\\Chrome\\Application\\chrome.exe"
        },
        "args": [
            "${file}"
        ]
    }
]
}

答案 3 :(得分:0)

只是添加到AlphaPage和John Papa的答案(我没有足够的代表添加评论),如果你全局安装gulp(npm install gulp -g),你有一个gulpfile.js根,当你:

  1. 打开命令面板(Ctrl + Shift + P)
  2. 键入Tasks,然后点击配置任务管理器
  3. 然后Alphapage列出的tasks.json将自动创建(如果它尚不存在)。并且将自动检测gulp任务。

相关问题