mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at rm-broken-strings 49 lines 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(path.join( 13 projectRoot, 14 'web-build/asset-manifest.json', 15)) 16 17console.log(`Found ${entrypoints.length} entrypoints`) 18console.log(`Writing ${templateFile}`) 19 20const outputFile = entrypoints 21 .map(name => { 22 const file = path.basename(name) 23 const ext = path.extname(file) 24 25 if (ext === '.js') { 26 return `<script defer="defer" src="{{ staticCDNHost }}/static/js/${file}"></script>` 27 } 28 if (ext === '.css') { 29 return `<link rel="stylesheet" href="{{ staticCDNHost }}/static/css/${file}">` 30 } 31 32 return '' 33 }) 34 .join('\n') 35fs.writeFileSync(templateFile, outputFile) 36 37function copyFiles(sourceDir, targetDir) { 38 const files = fs.readdirSync(path.join(projectRoot, sourceDir)) 39 files.forEach(file => { 40 const sourcePath = path.join(projectRoot, sourceDir, file) 41 const targetPath = path.join(projectRoot, targetDir, file) 42 fs.copyFileSync(sourcePath, targetPath) 43 console.log(`Copied ${sourcePath} to ${targetPath}`) 44 }) 45} 46 47copyFiles('web-build/static/js', 'bskyweb/static/js') 48copyFiles('web-build/static/css', 'bskyweb/static/css') 49copyFiles('web-build/static/media', 'bskyweb/static/media')