You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gulp构建任务执行失败求助:build与copy-css任务未完成,提示未触发异步完成信号

Fixing Gulp's "Did you forget to signal async completion?" Error

Hey there! Let's break down why your Gulp build is hitting that frustrating async completion error.

First, let's recap the error you're seeing:

[21:36:38] The following tasks did not complete: build, copy-css
Did you forget to signal async completion?

This error pops up when Gulp doesn't get clear confirmation that a task finished running. Looking at your code, the root issue is in how you're using postcss in the copy-css task—you're calling postcss() without passing any plugin arguments. PostCSS expects an array of plugins to execute (even an empty array if you don't need transformations right now), and without that input, it can't properly process the CSS stream, leaving the task hanging indefinitely.

Here's the simple fix:

Update your copy-css task to pass an empty array to postcss() (or add any PostCSS plugins you want to use, like autoprefixer, if needed):

gulp.task('copy-css', function () {
    return gulp.src('src/main/resources/**/*.css')
        .pipe(postcss([])) // Add empty array here (or your desired plugins)
        .pipe(production(uglifycss()))
        .pipe(gulp.dest('target/classes/'));
});

Why this works:

Gulp 4+ requires tasks to signal completion in one of three ways: returning a stream, calling a done callback, or using an async function. Your copy-css task does return a stream, but the incomplete PostCSS call was breaking that stream's lifecycle. By passing an empty plugin array, you let PostCSS properly process the files and close the stream, so Gulp recognizes the task as finished.

Give this a try, then re-run your build task—it should complete without errors now!

内容的提问来源于stack exchange,提问作者9527 snl

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 06:37:37