Ad
Gulp 4 Multiple Async Subtasks
how do I run multiple async subtasks in the Gulp task? In general, this task runs and starts copying the files but throws an error at the end.
The following tasks did not complete: build, copy:default
Did you forget to signal async completion?
gulp.task('copy:default', () => {
const fonts = gulp.src(['src/fonts/**/*'])
.pipe(gulp.dest('dist/fonts'));
const images = gulp.src(['src/images/**/*'])
.pipe(gulp.dest('dist/images'));
const scripts = gulp.src(['src/scripts/**/*'])
.pipe(gulp.dest('dist/scripts'));
return ['fonts', 'images', 'scripts']
});
I'm using this like this:
gulp.task('build', gulp.series('clean:dist', 'copy:default', 'sass'));
Ad
Answer
Here's a working solution:
gulp.task('copy:default', () => {
const finalPromise = new Promise(finalResolve => {
const fonts = new Promise(resolve => {
gulp.src(['src/fonts/**/*'])
.pipe(gulp.dest('dist/fonts'))
.on('end', resolve);
})
const images = new Promise(resolve => {
gulp.src(['src/images/**/*'])
.pipe(gulp.dest('dist/images'))
.on('end', resolve)
})
const scripts = new Promise(resolve => {
gulp.src(['src/scripts/**/*'])
.pipe(gulp.dest('dist/scripts'))
.on('end', resolve);
})
Promise.all([fonts, images, scripts]).then(result => {
finalResolve(result);
});
});
return finalPromise;
});
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad