From 5dd3fa843fae02b41116846e349503d54901b19e Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Fri, 3 Dec 2021 11:55:35 -0500 Subject: [PATCH] Add support for watching multiple view paths Added routine to convert `paths.views` into an array. Supports a single path as a string, a map of paths, or a list of paths: ```json "views": "./views/boilerplate/template" ``` ```json "views": { "src": "./views/boilerplate/template" } ``` ```json "views": [ "./views/boilerplate/template" ] ``` --- build/watch.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/build/watch.js b/build/watch.js index 6f88def..3a0a0b2 100644 --- a/build/watch.js +++ b/build/watch.js @@ -9,6 +9,21 @@ import { join } from 'node:path'; const { paths, tasks } = loconfig; +// Convert view(s) to an array +switch (typeof paths.views) { + case 'string': + paths.views = [ paths.views ]; + break; + + case 'object': + if (paths.views == null) { + paths.views = []; + } else if (!Array.isArray(paths.views)) { + paths.views = Object.values(paths.views); + } + break; +} + const serverConfig = { open: false, notify: false @@ -38,7 +53,7 @@ compileSVGs(...developmentSVGsArgs); // Reload on any changes to views or processed files server.watch( [ - paths.views.src, + ...paths.views, join(paths.scripts.dest, '*.js'), join(paths.styles.dest, '*.css'), join(paths.svgs.dest, '*.svg'),