0

How can I apply a condition argument based on if gulp is watching or not?

gulp.task('styles', function(){
    return gulp.src('sass/**/*.scss')
    .pipe(sass())
    if (isWatching) {
        // gulp.dest to the .tmp directory if "gulp watch"
        .pipe(gulp.dest('.tmp/css/'));
    } else {
        // gulp.dest to the distribution directory if "gulp" (or anything else)
        .pipe(gulp.dest('dist'));
    }
});

1 Answers1

0

How about:

gulp.task('styles', function(){
    var destPath = isWatching ? '.tmp/css/' : 'dist';

    return gulp.src('sass/**/*.scss')
        .pipe(sass())
        .pipe(gulp.dest(destPath));
});
thataustin
  • 2,035
  • 19
  • 18