Skip to content

Commit

Permalink
use node global context to get assetManifest. Relies on the Antora ex…
Browse files Browse the repository at this point in the history
…tension
  • Loading branch information
colegoldsmith committed May 31, 2024
1 parent 626aeb3 commit 55d5f01
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/helpers/assets-manifest.js
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]
}

0 comments on commit 55d5f01

Please sign in to comment.