Answer the question
In order to leave comments, you need to log in
What is the difference in gulp, return gulp.src(...) and cb()?
1- way via cb
const html = (cb) => {
gulp.src(config.src.html)
.pipe(plumber())
.pipe(include())
.pipe(gulpif(config.isProd, htmlmin({
collapseWhitespace: true,
removeComments: true,
})))
.pipe(gulp.dest(config.build.html))
cb();
}
const html = () => {
return gulp.src(config.src.html)
.pipe(plumber())
.pipe(include())
.pipe(gulpif(config.isProd, htmlmin({
collapseWhitespace: true,
removeComments: true,
})))
.pipe(gulp.dest(config.build.html))
}
Answer the question
In order to leave comments, you need to log in
In the first case, your callback fires immediately, and not after the task is completed.
It is correct to write like this:
const html = (cb) => {
gulp.src(config.src.html)
.on('end', cb) // Вызвать коллбэк после завершения таска.
.pipe(plumber())
.pipe(include())
.pipe(gulpif(config.isProd, htmlmin({
collapseWhitespace: true,
removeComments: true,
})))
.pipe(gulp.dest(config.build.html))
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question