Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Grunt tasks from within VSCode?

Title says it all. I still use Grunt, though it feels like I should be using Gulp.

Nonetheless, rather than alt-tabbing to a CMD window, I'd like to use the palette or shortcut keys to kick off some Grunt tasks. Reading the docs, it looks like I'd need to write a json task. What??? That's like writing a Grunt task to run a Grunt task.

Has anybody else already written a generic VSCode task for running Grunt?

EDIT: Thanks to the accepted answer, here is what I'm running:

{
    "version": "0.1.0", 
    "command": "grunt",
    "isShellCommand": true,
    "tasks": [{
        "taskName": "default"
    },{
        "taskName": "stage"
    },{
        "taskName": "dist"
    }]
}

I open the palette, and see default, stage, dist. Not sure if that's the best way, but it works so far. Definitely room for improvement.

like image 652
AJ Morris Avatar asked Apr 30 '15 12:04

AJ Morris


People also ask

How do I run local grunt?

Installing grunt-cli locally If you prefer the idiomatic Node. js method to get started with a project ( npm install && npm test ) then install grunt-cli locally with npm install grunt-cli --save-dev. Then add a script to your package. json to run the associated grunt command: "scripts": { "test": "grunt test" } .


1 Answers

The most recen update to VSC has auto-detects grunt (and gulp tasks) so you can now just use cmd+p then type task (notice the space at the end) and VSC will show you the available tasks to run.

This is how it looks

More info at: https://code.visualstudio.com/Docs/editor/tasks

like image 136
jluna Avatar answered Oct 17 '22 09:10

jluna