我的 gulpfile.js 如下所示,
var gulp = require('gulp');
var pug = require('gulp-pug');
var sass = require('gulp-sass');
var minifyCSS = require('gulp-csso');
var concat = require('gulp-concat');
var sourcemaps = require('gulp-sourcemaps');
var connect = require('gulp-connect');
gulp.task('connect', function () {
connect.server({
root: 'build',
livereload: true,
port: 3000
});
});
gulp.task('html', function () {
return gulp.src('client/html/**/*.pug')
.pipe(pug({
pretty: true
}))
.pipe(gulp.dest('build'))
.pipe(connect.reload())
});
gulp.task('css', function () {
return gulp.src(['node_modules/bootstrap/scss/bootstrap.scss', 'client/scss/*.scss'])
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(gulp.dest('build/css'))
.pipe(connect.reload())
});
gulp.task('images', function () {
return gulp.src(['client/assets/**/*.*'])
.pipe(gulp.dest('build/assets'))
.pipe(connect.reload())
});
gulp.task('js', function () {
return gulp.src('client/javascript/*.js')
.pipe(sourcemaps.init())
.pipe(concat('app.min.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('build/js'))
.pipe(connect.reload())
});
gulp.task('watch', gulp.parallel('html', 'css', 'js'));
gulp.task('default', gulp.series('connect', 'watch', 'html', 'css', 'images', 'js'));
当我运行此代码时,我在控制台上没有收到任何错误,而且浏览器上也不会自动重新加载。我在以前版本的 Gulp 中做到了这一点,但无法以某种方式使用 Gulp 4 运行它。现在每当我停止服务器时,我都会遇到以下错误,
[18:44:35] The following tasks did not complete: default, connect
[18:44:35] Did you forget to signal async completion?
任何帮助将不胜感激。谢谢