From a4137c6371dfd0b26a262c45e6f42ed4b4a5023c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renato=20de=20Le=C3=A3o?= Date: Thu, 6 Oct 2016 02:02:55 +0100 Subject: [PATCH] Organize const functions - build, serve and deploy functions - default gulp function is now serve --- gulpfile.babel.js | 66 ++++++++++++++++++++++++++++++++++++++++++----- package.json | 1 + 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 0c358f6..6500d67 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -166,7 +166,30 @@ export function paniniRebuild() { }; -export function watch(done) { +/* + * Local server using BrowserSync + */ +export function browserSyncServer(done){ + var config = { + server: { + baseDir: paths.appRoot.dest, + } + } + //run TUNNEL=true gulp to start public tunnel url to share. + if (process.env.TUNNEL === 'true') { + config.tunnel = ""; + } + + browserSync.init(config); + done() +} + + + +/* + * Listen for Changes + */ +export function watch() { gulp.watch(paths.images.src, images); gulp.watch(paths.fonts.src, fonts); gulp.watch(paths.styles.src, styles); @@ -174,10 +197,14 @@ export function watch(done) { gulp.watch(paths.views.src, paniniRebuild()); $.util.log($.util.colors.bgGreen('Watching for changes...')); - done() } +/* + * Build + * + * Create a deployable folder + */ const build = gulp.series( clean, gulp.parallel( @@ -189,11 +216,36 @@ const build = gulp.series( ) ); -export { build }; -const serve = gulp.series( build, gulp.parallel(watch, browserSyncServer)); -export { serve }; /* - * Export a default task + * Serve + * + * Serve the deployable folder watch for changes and start a dev server + */ +const serve = gulp.series( + build, + gulp.parallel(watch, browserSyncServer) +); + + +/* + * Deploy To gitHubPages + * + * Serve the deployable folder watch for changes and start a dev server */ -export default build; +const deploy = gulp.series( + build, + function(){ + return gulp.src(appRoot.dest) + .pipe(ghPages()); + } +); + + + + +/* Export const functions */ +export { build, serve, deploy}; + +/* Default gulp task as serve*/ +export default serve; diff --git a/package.json b/package.json index f267e5a..caa397f 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "gulp-clean-css": "^2.0.13", "gulp-concat": "^2.6.0", "gulp-eslint": "^3.0.1", + "gulp-gh-pages": "^0.5.4", "gulp-htmlmin": "^3.0.0", "gulp-if": "^2.0.1", "gulp-imagemin": "^3.0.3",