Is it possible to create a VS Code extension that runs a specific gulp task?

删除回忆录丶 提交于 2019-12-11 17:23:42

问题


Since I'm a lazy programmer, I've built a gulp task that does some minor tasks for me but I'd like to turn this into an extension so I can install it on my computer and it just "works". Like I install it, boot up VS code and the tasks execute and start watching my code automatically.

I haven't found much things online but then again I could be googling the wrong things. Anything helps - thanks!


回答1:


Have a look at run task on folderOpen option: vscode docs.

This works for me:

// in tasks.json

{
  "label": "Tasks: copy3",
  "type": "shell",
  "command": "gulp",
  "args": [
    "copy3",
    "--file",
    "${fileBasename}"
  ],
  "problemMatcher": [],
  "runOptions": {
    "runOn": "folderOpen"
  }
},

Now the copy3 task in gulpfile.js will automatically be run when that folder (or workspace) is opened. You may have to select Tasks: Allow Automatic Tasks in Folder first in the command palette. And definitely reload.

No extension - it is built-in behaviour more recently. See run task on folder open.




回答2:


Looks like Yuki Doi had you to it with "Blade Runner". This extension does exactly what you're looking for, it automatically runs build task when a folder is opened.

Related question



来源:https://stackoverflow.com/questions/56738821/is-it-possible-to-create-a-vs-code-extension-that-runs-a-specific-gulp-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!