| 1 | import { $ } from "bun"; |
| 2 | |
| 3 | // Clean up dist |
| 4 | await $`rm -rf site-dist`; |
| 5 | // Create new dist |
| 6 | await $`cp -r site site-dist`; |
| 7 | // Compile tailwindcss |
| 8 | await $`bunx @tailwindcss/cli -i ./site/input.css -o ./site-dist/output.css `; |
| 9 | // Build components |
| 10 | await $`bun run build`; |
| 11 | // Copy components over |
| 12 | await $`cp -r dist/components site-dist/components`; |
| 13 | |
| 14 | // Read index file |
| 15 | const htmlContent = await Bun.file("site-dist/index.html").text(); |
| 16 | // Update script tags and css link |
| 17 | const updatedHtml = htmlContent |
| 18 | .replace( |
| 19 | `<script src="../src/components/connect-wallet.js"></script>`, |
| 20 | `<script src="components/connect-wallet.js"></script>`, |
| 21 | ) |
| 22 | .replace( |
| 23 | `<script src="../src/components/contract-call.js"></script>`, |
| 24 | `<script src="components/contract-call.js"></script>`, |
| 25 | ) |
| 26 | .replace( |
| 27 | `<script src="../src/components/contract-read.js"></script>`, |
| 28 | `<script src="components/contract-read.js"></script>`, |
| 29 | ) |
| 30 | .replace( |
| 31 | `<link rel="stylesheet" href="tailwindcss" />`, |
| 32 | `<link rel="stylesheet" href="output.css" />`, |
| 33 | ); |
| 34 | // Write file |
| 35 | await Bun.write("site-dist/index.html", updatedHtml); |