Skip to content

Commit d6b5283

Browse files
MattSturgeonphated
authored andcommitted
Docs: Improve ES2015 task exporting examples (#1999)
1 parent f994cc7 commit d6b5283

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,12 @@ const paths = {
145145
};
146146

147147
/*
148-
* For small tasks you can use arrow functions and export
148+
* For small tasks you can export arrow functions
149149
*/
150-
const clean = () => del([ 'assets' ]);
151-
export { clean };
150+
export const clean = () => del([ 'assets' ]);
152151

153152
/*
154-
* You can still declare named functions and export them as tasks
153+
* You can also declare named functions and export them as tasks
155154
*/
156155
export function styles() {
157156
return gulp.src(paths.styles.src)
@@ -173,13 +172,21 @@ export function scripts() {
173172
.pipe(gulp.dest(paths.scripts.dest));
174173
}
175174

176-
export function watch() {
175+
/*
176+
* You could even use `export as` to rename exported tasks
177+
*/
178+
function watchFiles() {
177179
gulp.watch(paths.scripts.src, scripts);
178180
gulp.watch(paths.styles.src, styles);
179181
}
182+
export { watchFiles as watch };
180183

181-
const build = gulp.series(clean, gulp.parallel(styles, scripts));
182-
export { build };
184+
/*
185+
* You can still use `gulp.task`
186+
* for example to set task names that would otherwise be invalid
187+
*/
188+
const clean = gulp.series(clean, gulp.parallel(styles, scripts));
189+
gulp.task('clean', clean);
183190

184191
/*
185192
* Export a default task

0 commit comments

Comments
 (0)