-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use node global context to get assetManifest. Relies on the Antora ex…
…tension (#139)
- Loading branch information
1 parent
626aeb3
commit ed28d4e
Showing
1 changed file
with
12 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
'use strict' | ||
|
||
const { execSync } = require('child_process') | ||
const fs = require('fs') | ||
const logger = require('@antora/logger')('assets-manifest-helper') | ||
|
||
module.exports = (assetPath) => { | ||
let manifestPath | ||
let manifest | ||
try { | ||
manifestPath = execSync('find ./build/site -name assets-manifest.json').toString().trim() | ||
manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8')) | ||
} catch (err) { | ||
logger.error(err) | ||
const manifest = global.assetsManifest | ||
if (!manifest) { | ||
logger.error( | ||
` | ||
Assets manifest not found in global context. | ||
The .js and .css files from the UI bundle will not be linked properly in the HTML. | ||
Ensure assets-manifest.json from the UI bundle is parsed and added | ||
to global.assetsManifest after uiLoader is complete. | ||
` | ||
) | ||
return assetPath | ||
} | ||
if (manifest) return manifest[assetPath] | ||
return assetPath | ||
return manifest[assetPath] | ||
} |