about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorMary <148872143+mary-ext@users.noreply.github.com>2024-09-02 15:59:04 +0700
committerGitHub <noreply@github.com>2024-09-02 01:59:04 -0700
commit05ac76fc8942ec9ceda83d0f35a61763ae9bbcb5 (patch)
treee4678126d7ffc61b943dd871def72b453be16bd7 /scripts
parent1225e8448524633466379d5ac00a78b53e1a9a51 (diff)
downloadvoidsky-05ac76fc8942ec9ceda83d0f35a61763ae9bbcb5.tar.zst
Don't eagerly load all JS assets (#3929)
Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/post-web-build.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/scripts/post-web-build.js b/scripts/post-web-build.js
index 5db378854..baaa7cb8b 100644
--- a/scripts/post-web-build.js
+++ b/scripts/post-web-build.js
@@ -2,7 +2,6 @@ const path = require('path')
 const fs = require('fs')
 
 const projectRoot = path.join(__dirname, '..')
-const webBuildJs = path.join(projectRoot, 'web-build', 'static', 'js')
 const templateFile = path.join(
   projectRoot,
   'bskyweb',
@@ -10,18 +9,18 @@ const templateFile = path.join(
   'scripts.html',
 )
 
-const jsFiles = fs.readdirSync(webBuildJs).filter(name => name.endsWith('.js'))
-jsFiles.sort((a, b) => {
-  // make sure main is written last
-  if (a.startsWith('main')) return 1
-  if (b.startsWith('main')) return -1
-  return a.localeCompare(b)
-})
+const {entrypoints} = require(path.join(
+  projectRoot,
+  'web-build/asset-manifest.json',
+))
 
-console.log(`Found ${jsFiles.length} js files in web-build`)
+console.log(`Found ${entrypoints.length} entrypoints`)
 console.log(`Writing ${templateFile}`)
 
-const outputFile = jsFiles
-  .map(name => `<script defer="defer" src="/static/js/${name}"></script>`)
+const outputFile = entrypoints
+  .map(name => {
+    const file = path.basename(name)
+    return `<script defer="defer" src="/static/js/${file}"></script>`
+  })
   .join('\n')
 fs.writeFileSync(templateFile, outputFile)