An ATproto social media client -- with an independent Appview.
at main 1.4 kB view raw
1const path = require('path') 2const fs = require('fs') 3 4const projectRoot = path.join(__dirname, '..') 5const templateFile = path.join( 6 projectRoot, 7 'bskyweb', 8 'templates', 9 'scripts.html', 10) 11 12const {entrypoints} = require( 13 path.join(projectRoot, 'web-build/asset-manifest.json'), 14) 15 16console.log(`Found ${entrypoints.length} entrypoints`) 17console.log(`Writing ${templateFile}`) 18 19const outputFile = entrypoints 20 .map(name => { 21 const file = path.basename(name) 22 const ext = path.extname(file) 23 24 if (ext === '.js') { 25 return `<script defer="defer" src="{{ staticCDNHost }}/static/js/${file}"></script>` 26 } 27 if (ext === '.css') { 28 return `<link rel="stylesheet" href="{{ staticCDNHost }}/static/css/${file}">` 29 } 30 31 return '' 32 }) 33 .join('\n') 34fs.writeFileSync(templateFile, outputFile) 35 36function copyFiles(sourceDir, targetDir) { 37 const files = fs.readdirSync(path.join(projectRoot, sourceDir)) 38 files.forEach(file => { 39 const sourcePath = path.join(projectRoot, sourceDir, file) 40 const targetPath = path.join(projectRoot, targetDir, file) 41 fs.copyFileSync(sourcePath, targetPath) 42 console.log(`Copied ${sourcePath} to ${targetPath}`) 43 }) 44} 45 46copyFiles('web-build/static/js', 'bskyweb/static/js') 47copyFiles('web-build/static/css', 'bskyweb/static/css') 48copyFiles('web-build/static/media', 'bskyweb/static/media')