如果gulp正在观看有条件的话

时间:2014-12-03 17:24:21

标签: gulp gulp-watch gulp-sass

如何根据gulp是否正在观看来应用条件参数?

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 个答案:

答案 0 :(得分:0)

怎么样:

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

    return gulp.src('sass/**/*.scss')
        .pipe(sass())
        .pipe(gulp.dest(destPath));
});