scripts/build.js 1.2 K raw
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")