参考配置 JavaScript 任务的方式配置 Sass 任务
gulp.task('watchsass',function () { gulp.watch('src/sass/**/*', function (event) { var paths = watchPath(event, 'src/sass/', 'dist/css/') gutil.log(gutil.colors.green(event.type) + ' ' + paths.srcPath) gutil.log('Dist ' + paths.distPath) sass(paths.srcPath) .on('error', function (err) { console.error('Error!', err.message); }) .pipe(sourcemaps.init()) .pipe(minifycss()) .pipe(autoprefixer({ browsers: 'last 2 versions' })) .pipe(sourcemaps.write('./')) .pipe(gulp.dest(paths.distDir)) }) }) gulp.task('sasscss', function () { sass('src/sass/') .on('error', function (err) { console.error('Error!', err.message); }) .pipe(sourcemaps.init()) .pipe(minifycss()) .pipe(autoprefixer({ browsers: 'last 2 versions' })) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('dist/css')) }) gulp.task('default', ['watchjs', 'watchcss', 'watchless', 'watchsass', 'watchsass'])