further simplify the preview:serve task
authorDan Allen <dan@opendevise.com>
Sun, 30 Dec 2018 21:03:39 +0000 (14:03 -0700)
committerDan Allen <dan@opendevise.com>
Sun, 30 Dec 2018 21:03:39 +0000 (14:03 -0700)
- move watch function to third argument of previewServe function

gulpfile.js/index.js
gulpfile.js/tasks/preview-serve.js

index d2f2396..c9f01b8 100644 (file)
@@ -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({
index 8ae70cf..c9a9c25 100644 (file)
@@ -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()
   })
 }