Skip to content

Commit

Permalink
Improve ES2015 task exporting examples for 4.0
Browse files Browse the repository at this point in the history
Show exporting via `export const task = () + {}`, `gulp.task`,
`export { task as taskName }` and slightly tweaked some of the comment
explanations.
  • Loading branch information
MattSturgeon authored Jul 23, 2017
1 parent 38246c3 commit d780de5
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,12 @@ const paths = {
};

/*
* For small tasks you can use arrow functions and export
* For small tasks you can export arrow functions
*/
const clean = () => del([ 'assets' ]);
export { clean };
export const clean = () => del([ 'assets' ]);

/*
* You can still declare named functions and export them as tasks
* You can also declare named functions and export them as tasks
*/
export function styles() {
return gulp.src(paths.styles.src)
Expand All @@ -173,13 +172,21 @@ export function scripts() {
.pipe(gulp.dest(paths.scripts.dest));
}

export function watch() {
/*
* You could even use `export as` to rename exported tasks
*/
function watchFiles() {
gulp.watch(paths.scripts.src, scripts);
gulp.watch(paths.styles.src, styles);
}
export { watchFiles as watch };

const build = gulp.series(clean, gulp.parallel(styles, scripts));
export { build };
/*
* You can still use `gulp.task`
* for example to set task names that would otherwise be invalid
*/
const clean = gulp.series(clean, gulp.parallel(styles, scripts));
gulp.task('clean', clean);

/*
* Export a default task
Expand Down

0 comments on commit d780de5

Please sign in to comment.