How can I utilize Gulp.watch in Visual Studio 2015?

4.2k views Asked by At

I want to apply a Gulp watcher to my LESS files so Gulp will create css files whenever a LESS file gets saved.

How can I do this? It doesn't seem to be correct/sufficient to write something like this:

var gulp = require("gulp");
var moreLess = require("gulp-more-less");
var concatCss = require("gulp-concat-css");

var lessInFolder = "./Less/**/*.less";

gulp.task("less", function ()
{
  gulp.src(lessInFolder).pipe(moreless()).pipe(concatCss()).pipe(gulp.dest("./css"));
});

gulp.watch(lessInFolder, ["less"]);
1

There are 1 answers

4
Chtioui Malek On BEST ANSWER

Create a dedicated task for the watch function :

gulp.task('default', function () {
    gulp.watch(lessInFolder, ['less']);
});

then use the visual studio Task Runner Explorer to execute (or bind) that task.