2023-03-14 23:30:15 +01:00
|
|
|
const path = require('path')
|
|
|
|
const fs = require('fs')
|
|
|
|
|
|
|
|
const projectRoot = path.join(__dirname, '..')
|
|
|
|
const templateFile = path.join(
|
|
|
|
projectRoot,
|
|
|
|
'bskyweb',
|
|
|
|
'templates',
|
|
|
|
'scripts.html',
|
|
|
|
)
|
|
|
|
|
2024-09-02 10:59:04 +02:00
|
|
|
const {entrypoints} = require(path.join(
|
|
|
|
projectRoot,
|
|
|
|
'web-build/asset-manifest.json',
|
|
|
|
))
|
2023-03-14 23:30:15 +01:00
|
|
|
|
2024-09-02 10:59:04 +02:00
|
|
|
console.log(`Found ${entrypoints.length} entrypoints`)
|
2023-03-14 23:30:15 +01:00
|
|
|
console.log(`Writing ${templateFile}`)
|
|
|
|
|
2024-09-02 10:59:04 +02:00
|
|
|
const outputFile = entrypoints
|
|
|
|
.map(name => {
|
|
|
|
const file = path.basename(name)
|
|
|
|
return `<script defer="defer" src="/static/js/${file}"></script>`
|
|
|
|
})
|
2023-03-14 23:30:15 +01:00
|
|
|
.join('\n')
|
|
|
|
fs.writeFileSync(templateFile, outputFile)
|