【问题标题】:Gulp error: The following tasks did not complete: default, sassGulp 错误:以下任务未完成:默认、sass
【发布时间】:2021-07-29 06:41:34
【问题描述】:

我为我正在构建的项目创建了一个 gulpfile.js 文件。当我尝试运行它时,我得到了这个错误。

[18:29:03] Using gulpfile ~\Documents\codeprojects\antenna\gulpfile.js
[18:29:03] Starting 'default'...
[18:29:03] Starting 'sass'...
[18:29:03] The following tasks did not complete: default, sass
[18:29:03] Did you forget to signal async completion?

这是我的 gulpfile.js 代码

var gulp = require('gulp');
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');

gulp.task('sass', function() {
    gulp.src('public/stylesheets/style.scss')
      .pipe(plumber())
      .pipe(sass())
      .pipe(gulp.dest('public/stylesheets'));
});

gulp.task('watch', function() {
    gulp.watch('public/stylesheets/*.scss', ['sass']);
});

gulp.task('default', gulp.series('sass', 'watch'));

【问题讨论】:

    标签: javascript node.js sass gulp


    【解决方案1】:
    gulp.task('sass', function() {
        return gulp.src('public/stylesheets/style.scss')  // return added here
          .pipe(plumber())
          .pipe(sass())
          .pipe(gulp.dest('public/stylesheets'));
    });
    
    // the return above will suffice to "signal async completion"
    
    gulp.task('watch', function() {
        // gulp.watch('public/stylesheets/*.scss', ['sass']);  // old gulp v3 synatx
        gulp.watch('public/stylesheets/*.scss', gulp.series('sass'));  // v4 syntax
    });
    

    另外,您需要切换到插件gulp-dart-sass 而不是gulp-sass。它支持更新的功能,例如 @use

    【讨论】:

      猜你喜欢
      • 2021-10-26
      • 2023-03-10
      • 1970-01-01
      • 2016-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-25
      相关资源
      最近更新 更多