1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00

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"
]
```
This commit is contained in:
Chauncey McAskill
2021-12-03 11:55:35 -05:00
parent a5623d3122
commit 5dd3fa843f

View File

@@ -9,6 +9,21 @@ import { join } from 'node:path';
const { paths, tasks } = loconfig; 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 = { const serverConfig = {
open: false, open: false,
notify: false notify: false
@@ -38,7 +53,7 @@ compileSVGs(...developmentSVGsArgs);
// Reload on any changes to views or processed files // Reload on any changes to views or processed files
server.watch( server.watch(
[ [
paths.views.src, ...paths.views,
join(paths.scripts.dest, '*.js'), join(paths.scripts.dest, '*.js'),
join(paths.styles.dest, '*.css'), join(paths.styles.dest, '*.css'),
join(paths.svgs.dest, '*.svg'), join(paths.svgs.dest, '*.svg'),