Gulp 4 你忘了发出异步完成信号吗?

标签 gulp

我正在尝试使用 gulp sass 构建我的 sass,但出现错误:

以下任务未完成:构建、清理 您是否忘记发出异步完成信号?

gulp.task('clean', function() { return del.sync('dist'); });

 gulp.task('build', gulp.series('clean', 'imagemin', 'sass', 'js', function(done) {

var buildMain = gulp.src([
    'app/*.html',
    'app/.htaccess'
]).pipe(gulp.dest('dist'));

var buildCss = gulp.src([
    'app/css/main.min.css'
    ])
.pipe(gulp.dest('dist/css'));

var buildJs =  gulp.src([
    'app/js/scripts.min.js'
    ])
.pipe(gulp.dest('dist/js'));

var buildFonts = gulp.src([
    'app/fonts/**/*'
    ])
.pipe(gulp.dest('dist/fonts'));
done(); }));

最佳答案

Sven Schoenung在这说question :

This is a much more fitting mechanism for your use case. Note that most of the time you won't have to create the Promise object yourself, it will usually be provided by a package (e.g. the frequently used del package returns a Promise).

我尝试了这种方法,对我来说很有效。代码将是:

gulp.task('clean:dist', function (resolve) {
  del.sync('dist');
  resolve();
})

关于Gulp 4 你忘了发出异步完成信号吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53998102/

相关文章:

javascript - 当我输入 npm start 时如何启动 Gulp watch 任务

javascript - Gulp.js 以特定顺序阻塞运行任务

javascript - 当我将函数抽象为命名函数时,为什么此回调未定义?

gulp-angular-templatecache 无法找到它创建的模板文件

css - 我的 gulp iconfont 呈现得像一个丑陋的实时跟踪图标

gulp - Gulp-删除本地插件

Gulp:如何自动替换 html 中的缩小文件?

angular - 在 scss 保存时重新加载页面

javascript - 使用 Gulp 将咖啡和 js 开发结合起来

javascript - 在 gulp 中注入(inject) js 和 css 时,如何提供对 index.html 的写权限?