33 lines
767 B
JavaScript
33 lines
767 B
JavaScript
import { spawnSync } from 'node:child_process'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
const frontendRoot = join(__dirname, '..')
|
|
const bunBin = process.execPath
|
|
const env = {
|
|
...process.env,
|
|
PLANET_FRONTEND_TARGET: 'admin',
|
|
}
|
|
|
|
const tscResult = spawnSync(bunBin, ['x', 'tsc'], {
|
|
cwd: frontendRoot,
|
|
env,
|
|
stdio: 'inherit',
|
|
})
|
|
if ((tscResult.status ?? 1) !== 0) {
|
|
process.exit(tscResult.status ?? 1)
|
|
}
|
|
|
|
const viteArgs = [
|
|
join(frontendRoot, 'node_modules/vite/bin/vite.js'),
|
|
'build',
|
|
...process.argv.slice(2),
|
|
]
|
|
const viteResult = spawnSync(bunBin, viteArgs, {
|
|
cwd: frontendRoot,
|
|
env,
|
|
stdio: 'inherit',
|
|
})
|
|
process.exit(viteResult.status ?? 1)
|