Add distribution metadata, Strobi app icons, CI, and comprehensive documentation. Migrate the project to pnpm and reorganize the Studio into domain-focused modules and components.
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
import { readFile, writeFile } from 'node:fs/promises'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
import { build } from 'vite'
|
|
|
|
const root = path.dirname(path.dirname(fileURLToPath(import.meta.url)))
|
|
const result = await build({
|
|
configFile: false,
|
|
logLevel: 'silent',
|
|
build: {
|
|
write: false,
|
|
minify: true,
|
|
lib: {
|
|
entry: path.join(root, 'src/features/export/standaloneEngine.entry.ts'),
|
|
formats: ['iife'],
|
|
name: 'AvatarProceduralEngine',
|
|
},
|
|
},
|
|
})
|
|
const outputs = Array.isArray(result) ? result.flatMap(item => item.output) : result.output
|
|
const chunk = outputs.find(item => item.type === 'chunk')
|
|
if (!chunk) throw new Error('Standalone avatar engine bundle was not generated.')
|
|
|
|
const outputPath = path.join(root, 'src/features/export/standaloneEngine.generated.ts')
|
|
const source = `// Generated by scripts/generate-standalone-engine.mjs. Do not edit.\nexport const standaloneEngineSource = ${JSON.stringify(chunk.code)}\n`
|
|
|
|
if (process.argv.includes('--check')) {
|
|
const current = await readFile(outputPath, 'utf8').catch(() => '')
|
|
if (current !== source) throw new Error('Standalone avatar engine is stale. Run pnpm engine.')
|
|
} else {
|
|
await writeFile(outputPath, source)
|
|
}
|