以下任务没有完成:serve,sass。您是否忘记发信号异步完成?

时间:2018-03-14 01:54:17

标签: gulp

其他答案没有帮助。我在Windows 10上使用Gulp 4。

运行' gulp serve'

时出现以下错误
The following tasks did not complete: serve, sass
[18:48:51] Did you forget to signal async completion?

我的gulpfile.js

var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync');
var reload = browserSync.reload;

gulp.task('sass', function() {
    return sass('./public_html/lib/scss/main.scss')
        .pipe(gulp.dest('./public_html/css'))
        .pipe(reload({ stream:true }));
});
gulp.task('serve', gulp.series('sass', function() {
    browserSync({
        server: {
            baseDir: 'public_html'
        }
    });
    gulp.watch('lib/scss/*.scss', gulp.series('sass'));
}));

1 个答案:

答案 0 :(得分:4)

请改为尝试:

gulp.task('sass', function() {

    return gulp.src('./public_html/lib/sass/main.scss')
        .pipe(sass()).on("error", sass.logError))
        .pipe(gulp.dest('./public_html/css'))
        .pipe(reload({ stream:true }));
});

注意你需要gulp.src,然后调用sass。