From 39efbaff1dfaaa317b1383bcde379f637c4a4143 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sun, 30 Dec 2018 14:03:39 -0700 Subject: further simplify the preview:serve task - move watch function to third argument of previewServe function --- gulpfile.js/index.js | 4 ++-- gulpfile.js/tasks/preview-serve.js | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/gulpfile.js/index.js b/gulpfile.js/index.js index d2f2396..c9f01b8 100644 --- a/gulpfile.js/index.js +++ b/gulpfile.js/index.js @@ -1,6 +1,6 @@ 'use strict' -const { parallel, series, tree } = require('gulp') +const { parallel, series, tree, watch } = require('gulp') const task = require('./lib/task') const bundleName = 'ui' @@ -84,7 +84,7 @@ const previewBuildTask = task({ const previewServeTask = task({ name: 'preview:serve', - call: previewServe(previewDestDir, { port: 5252, livereload, watch: { glob: glob.all, call: previewBuildTask } }), + call: previewServe(previewDestDir, { port: 5252, livereload }, () => watch(glob.all, previewBuildTask)), }) const previewTask = task({ diff --git a/gulpfile.js/tasks/preview-serve.js b/gulpfile.js/tasks/preview-serve.js index 8ae70cf..c9a9c25 100644 --- a/gulpfile.js/tasks/preview-serve.js +++ b/gulpfile.js/tasks/preview-serve.js @@ -1,14 +1,10 @@ 'use strict' const connect = require('gulp-connect') -const { watch } = require('gulp') -module.exports = (serveDir, opts = {}) => (done) => { - const { glob: watchGlob, call: watchCall } = opts.watch || {} - opts = { ...opts, root: serveDir } - delete opts.watch - connect.server(opts, function () { +module.exports = (serveDir, opts = {}, watch = undefined) => (done) => { + connect.server({ ...opts, root: serveDir }, function () { this.server.on('close', done) - if (watchGlob && watchCall) watch(watchGlob, watchCall) + if (watch) watch() }) } -- cgit v1.2.3