parent
1225e84485
commit
05ac76fc89
|
@ -2,7 +2,6 @@ const path = require('path')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
const projectRoot = path.join(__dirname, '..')
|
const projectRoot = path.join(__dirname, '..')
|
||||||
const webBuildJs = path.join(projectRoot, 'web-build', 'static', 'js')
|
|
||||||
const templateFile = path.join(
|
const templateFile = path.join(
|
||||||
projectRoot,
|
projectRoot,
|
||||||
'bskyweb',
|
'bskyweb',
|
||||||
|
@ -10,18 +9,18 @@ const templateFile = path.join(
|
||||||
'scripts.html',
|
'scripts.html',
|
||||||
)
|
)
|
||||||
|
|
||||||
const jsFiles = fs.readdirSync(webBuildJs).filter(name => name.endsWith('.js'))
|
const {entrypoints} = require(path.join(
|
||||||
jsFiles.sort((a, b) => {
|
projectRoot,
|
||||||
// make sure main is written last
|
'web-build/asset-manifest.json',
|
||||||
if (a.startsWith('main')) return 1
|
))
|
||||||
if (b.startsWith('main')) return -1
|
|
||||||
return a.localeCompare(b)
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(`Found ${jsFiles.length} js files in web-build`)
|
console.log(`Found ${entrypoints.length} entrypoints`)
|
||||||
console.log(`Writing ${templateFile}`)
|
console.log(`Writing ${templateFile}`)
|
||||||
|
|
||||||
const outputFile = jsFiles
|
const outputFile = entrypoints
|
||||||
.map(name => `<script defer="defer" src="/static/js/${name}"></script>`)
|
.map(name => {
|
||||||
|
const file = path.basename(name)
|
||||||
|
return `<script defer="defer" src="/static/js/${file}"></script>`
|
||||||
|
})
|
||||||
.join('\n')
|
.join('\n')
|
||||||
fs.writeFileSync(templateFile, outputFile)
|
fs.writeFileSync(templateFile, outputFile)
|
||||||
|
|
Loading…
Reference in New Issue