about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-03-14 17:30:15 -0500
committerGitHub <noreply@github.com>2023-03-14 17:30:15 -0500
commit8d2e649b4dae4523d9c0ac36d5dfd31409447be4 (patch)
tree151f1dcd76c52a8bb3f45061a023fe6a8b2637b2 /scripts
parent8629e167cd668cd1d41bf6a37acf9d94502e5c2b (diff)
downloadvoidsky-8d2e649b4dae4523d9c0ac36d5dfd31409447be4.tar.zst
Create build step for the web server (#289)
* Create build step for the web server

* Update bskyweb routes and 404 behavior
Diffstat (limited to 'scripts')
-rw-r--r--scripts/post-web-build.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/post-web-build.js b/scripts/post-web-build.js
new file mode 100644
index 000000000..5db378854
--- /dev/null
+++ b/scripts/post-web-build.js
@@ -0,0 +1,27 @@
+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',
+  'templates',
+  '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)
+})
+
+console.log(`Found ${jsFiles.length} js files in web-build`)
+console.log(`Writing ${templateFile}`)
+
+const outputFile = jsFiles
+  .map(name => `<script defer="defer" src="/static/js/${name}"></script>`)
+  .join('\n')
+fs.writeFileSync(templateFile, outputFile)