feat: move to typescript, miniplex ecs

This commit is contained in:
2026-09-05 12:07:22 +05:00
parent 63f9885e46
commit f6596f765e
69 changed files with 3932 additions and 1838 deletions
+26 -6
View File
@@ -1,12 +1,13 @@
import { build, context } from 'esbuild'
import { cpSync, copyFileSync, mkdirSync, readdirSync, rmSync } from 'node:fs'
import { dirname, join, relative } from 'node:path'
import { fileURLToPath } from 'node:url'
const root = dirname(fileURLToPath(import.meta.url))
const dist = join(root, 'dist')
const watch = process.argv.includes('--watch')
const rootFiles = ['index.html', 'game.html', 'style.css', 'serve.json']
const jsDir = 'js'
const imgFiles = ['sprite.svg']
function listFiles(dir) {
@@ -22,14 +23,33 @@ for (const file of rootFiles) {
copyFileSync(join(root, file), join(dist, file))
}
cpSync(join(root, jsDir), join(dist, jsDir), { recursive: true })
mkdirSync(join(dist, 'img'))
for (const file of imgFiles) {
copyFileSync(join(root, 'img', file), join(dist, 'img', file))
}
console.log('Собрано в dist:')
for (const file of listFiles(dist)) {
console.log(' ' + relative(dist, file))
const options = {
entryPoints: {
game: join(root, 'src/entries/game.ts'),
index: join(root, 'src/entries/index.ts'),
},
outdir: dist,
bundle: true,
minify: true,
sourcemap: false,
format: 'iife',
target: 'es2020',
logLevel: 'info',
}
if (watch) {
const contexts = await Promise.all([context(options)])
await Promise.all(contexts.map((c) => c.watch()))
console.log('Слежу за изменениями src/...')
} else {
await build(options)
console.log('Собрано в dist:')
for (const file of listFiles(dist)) {
console.log(' ' + relative(dist, file))
}
}