| 1 | #!/usr/bin/env bun |
| 2 | import { $ } from "bun" |
| 3 | import { existsSync, rmSync, mkdirSync } from "fs" |
| 4 | |
| 5 | const DIST_DIR = "./dist" |
| 6 | const PUBLIC_DIR = "./public" |
| 7 | |
| 8 | console.log("๐ฆ Building Dino Game...\n") |
| 9 | |
| 10 | // Clean and create dist |
| 11 | if (existsSync(DIST_DIR)) { |
| 12 | console.log("๐งน Cleaning dist directory...") |
| 13 | rmSync(DIST_DIR, { recursive: true, force: true }) |
| 14 | } |
| 15 | mkdirSync(DIST_DIR, { recursive: true }) |
| 16 | |
| 17 | // Build with Bun |
| 18 | console.log("๐ฆ Building bundle...") |
| 19 | await $`bun build ./index.html --outdir ${DIST_DIR}` |
| 20 | |
| 21 | // Copy assets |
| 22 | console.log("๐ Copying assets...") |
| 23 | await $`cp -r ${PUBLIC_DIR}/assets ${DIST_DIR}/assets` |
| 24 | |
| 25 | // Copy public files (icons, manifest, etc) |
| 26 | console.log("๐ผ๏ธ Copying icons and manifest...") |
| 27 | await $`cp ${PUBLIC_DIR}/*.png ${DIST_DIR}/`.quiet() |
| 28 | await $`cp ${PUBLIC_DIR}/*.ico ${DIST_DIR}/`.quiet() |
| 29 | await $`cp ${PUBLIC_DIR}/*.webmanifest ${DIST_DIR}/`.quiet() |
| 30 | |
| 31 | // Copy functions |
| 32 | console.log("โก Copying API functions...") |
| 33 | await $`cp -r ./functions ${DIST_DIR}/functions` |
| 34 | |
| 35 | // Copy config for API functions |
| 36 | console.log("โ๏ธ Copying config for API...") |
| 37 | mkdirSync(`${DIST_DIR}/src`, { recursive: true }) |
| 38 | await $`cp ./src/config.js ${DIST_DIR}/src/config.js` |
| 39 | |
| 40 | console.log("\nโ
Build complete! Output in ./dist") |