@uniweb/build 0.16.2 → 0.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/src/site/content-collector.js +20 -3
- package/src/site/plugin.js +20 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -59,15 +59,15 @@
|
|
|
59
59
|
"js-yaml": "^4.1.0",
|
|
60
60
|
"sharp": "^0.35.3",
|
|
61
61
|
"yaml": "^2.5.0",
|
|
62
|
-
"@uniweb/projections": "0.2.2",
|
|
63
62
|
"@uniweb/theming": "0.1.15",
|
|
64
|
-
"@uniweb/content-writer": "0.3.
|
|
63
|
+
"@uniweb/content-writer": "0.3.3",
|
|
64
|
+
"@uniweb/projections": "0.2.3"
|
|
65
65
|
},
|
|
66
66
|
"optionalDependencies": {
|
|
67
|
-
"@uniweb/content-reader": "1.2.
|
|
68
|
-
"@uniweb/
|
|
67
|
+
"@uniweb/content-reader": "1.2.2",
|
|
68
|
+
"@uniweb/semantic-parser": "1.2.0",
|
|
69
69
|
"@uniweb/runtime": "0.9.0",
|
|
70
|
-
"@uniweb/
|
|
70
|
+
"@uniweb/schemas": "0.2.4"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
@@ -376,6 +376,25 @@ function mountHasContent(dirPath) {
|
|
|
376
376
|
})
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
/**
|
|
380
|
+
* The `pages/<segment>` keys in a site.yml `paths:` group, unvalidated.
|
|
381
|
+
*
|
|
382
|
+
* Split out from resolveMounts so the dev server can learn which directories a
|
|
383
|
+
* site mounts without re-running resolveMounts' validation — that would repeat
|
|
384
|
+
* its warnings on every startup, and the watcher only needs paths. Both callers
|
|
385
|
+
* share this one definition of what a mount key looks like, so the prefix can
|
|
386
|
+
* never mean one thing to the collector and another to the watcher.
|
|
387
|
+
*
|
|
388
|
+
* @param {Object} pathsConfig - The paths: object from site.yml
|
|
389
|
+
* @returns {Array<[string, string]>} [routeSegment, relativePath] pairs
|
|
390
|
+
*/
|
|
391
|
+
export function mountEntriesOf(pathsConfig) {
|
|
392
|
+
if (!pathsConfig || typeof pathsConfig !== 'object') return []
|
|
393
|
+
return Object.entries(pathsConfig)
|
|
394
|
+
.filter(([key]) => key.startsWith('pages/'))
|
|
395
|
+
.map(([key, value]) => [key.slice('pages/'.length), value])
|
|
396
|
+
}
|
|
397
|
+
|
|
379
398
|
/**
|
|
380
399
|
* Extract page mounts from site.yml paths: config.
|
|
381
400
|
*
|
|
@@ -396,9 +415,7 @@ function resolveMounts(pathsConfig, sitePath, pagesPath, { strict = false } = {}
|
|
|
396
415
|
if (!pathsConfig || typeof pathsConfig !== 'object') return null
|
|
397
416
|
|
|
398
417
|
// Extract entries with "pages/" prefix (e.g., "pages/docs": "../../../docs")
|
|
399
|
-
const mountEntries =
|
|
400
|
-
.filter(([key]) => key.startsWith('pages/'))
|
|
401
|
-
.map(([key, value]) => [key.slice('pages/'.length), value])
|
|
418
|
+
const mountEntries = mountEntriesOf(pathsConfig)
|
|
402
419
|
|
|
403
420
|
if (mountEntries.length === 0) return null
|
|
404
421
|
|
package/src/site/plugin.js
CHANGED
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
applyRouteTranslation,
|
|
46
46
|
INDEX_FILENAME
|
|
47
47
|
} from '@uniweb/projections'
|
|
48
|
-
import { collectSiteContent } from './content-collector.js'
|
|
48
|
+
import { collectSiteContent, mountEntriesOf } from './content-collector.js'
|
|
49
49
|
import { processAssets, rewriteSiteContentPaths } from './asset-processor.js'
|
|
50
50
|
import { processAdvancedAssets } from './advanced-processors.js'
|
|
51
51
|
import { processCollections, writeCollectionFiles } from './collection-processor.js'
|
|
@@ -516,6 +516,7 @@ export function siteContentPlugin(options = {}) {
|
|
|
516
516
|
let localesDir = 'locales' // Default, updated from site config
|
|
517
517
|
let collectionsConfig = null // Cached for watcher setup
|
|
518
518
|
let resolvedPagesPath = null // Resolved from site.yml pagesDir or default
|
|
519
|
+
let resolvedMountPaths = [] // Absolute dirs mounted under pages/ via site.yml paths:
|
|
519
520
|
let resolvedLayoutPath = null // Resolved from site.yml layoutDir or default
|
|
520
521
|
let resolvedCollectionsBase = null // Resolved from site.yml collectionsDir
|
|
521
522
|
let headHtml = '' // Contents of site/head.html for injection
|
|
@@ -750,6 +751,7 @@ export function siteContentPlugin(options = {}) {
|
|
|
750
751
|
resolvedCollectionsBase = paths.collections
|
|
751
752
|
? resolve(resolvedSitePath, paths.collections)
|
|
752
753
|
: null
|
|
754
|
+
resolvedMountPaths = mountEntriesOf(paths).map(([, rel]) => resolve(resolvedSitePath, rel))
|
|
753
755
|
|
|
754
756
|
if (collectionsConfig) {
|
|
755
757
|
console.log('[site-content] Processing content collections...')
|
|
@@ -886,6 +888,23 @@ export function siteContentPlugin(options = {}) {
|
|
|
886
888
|
}
|
|
887
889
|
}
|
|
888
890
|
|
|
891
|
+
// Watch each directory mounted under pages/ by site.yml `paths:`.
|
|
892
|
+
//
|
|
893
|
+
// The site's own pages/ watcher above does not reach these — a mount
|
|
894
|
+
// lives outside the site, which is the whole point of one. Without this
|
|
895
|
+
// an author editing a mounted docs repository sees nothing change until
|
|
896
|
+
// they restart the dev server, and the natural reading of that is that
|
|
897
|
+
// their edit was wrong rather than unwatched.
|
|
898
|
+
for (const mountPath of resolvedMountPaths) {
|
|
899
|
+
if (!existsSync(mountPath)) continue
|
|
900
|
+
try {
|
|
901
|
+
watchers.push(watch(mountPath, { recursive: true }, scheduleRebuild))
|
|
902
|
+
console.log(`[site-content] Watching ${mountPath} (mounted)`)
|
|
903
|
+
} catch (err) {
|
|
904
|
+
console.warn(`[site-content] Could not watch mounted directory ${mountPath}:`, err.message)
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
|
|
889
908
|
// Watch layout directory (resolved from site.yml layoutDir or default)
|
|
890
909
|
if (existsSync(resolvedLayoutPath)) {
|
|
891
910
|
try {
|