UNPKG

create-amp-page

Version:

Full fledged static side generator composed out of extendable gulp tasks, optimized for - but not limited to - AMP.

38 lines (35 loc) 1.15 kB
import gulp from 'gulp' import gulpCopy from 'gulp-copy' export function makeCopyTask({copyPaths, dist, browsersync}) { function makeCopyTasks(copyInfo) { return function copy() { return gulp .src(copyInfo.src) .pipe(browsersync.stream()) .pipe(gulpCopy(dist, {prefix: copyInfo.prefix})) } } return { watch: (watchOptions) => { if(copyPaths) { let copies = copyPaths if(!Array.isArray(copies)) { copies = [copies] } copies.forEach(copyOne => { // todo: add something like "sync-the-files" instead of copy for watch gulp.watch(copyOne.src, watchOptions, makeCopyTasks(copyOne)) }) } }, build: copyPaths ? [ Array.isArray(copyPaths) ? copyPaths.map(copySingle => ( makeCopyTasks(copySingle) )) : makeCopyTasks(copyPaths), ] : [], } }