Basically I want to setup my task so that if I do gulp less --watch
it will watch, otherwise just do the build. This is what I have so far:
'use strict';
var gulp = require('gulp');
var less = require('gulp-less');
var gulpif = require('gulp-if');
var watch = require('gulp-watch');
var cli = require('minimist')(process.argv.slice(2));
gulp.task('less', function () {
return gulp.src(['./client/styles/styles.less', './client/styles/libs.less'])
.pipe(less({ sourceMap: !cli.production }))
.pipe(gulp.dest('./dist/styles'))
.pipe(gulpif(cli.watch, watch()));
});
What happens is that it still executes the watch
, but doesn't pass any files. This also prevents the task from process.exit()
ing..
I'm assuming I have to either wrap it in something, or use an alternate method (not gulp-if
)..