- build:renderer builds Fabric.Frontend with relative base and copies the static bundle into renderer/; dist/pack scripts run it first. - main.js: production loads renderer/index.html when present (falls back to offline.html); packaged app no longer needs a separate frontend server (still talks to Center/Guild backends, which the login screen points at — file:// origin is CORS-allowed). - package files += renderer/**; gitignore renderer/. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Build the Fabric web frontend with a relative asset base and copy the
|
|
* static bundle into Fabric.Desktop/renderer/ so the packaged Electron app
|
|
* is self-contained (loaded via file://, no separate web server needed).
|
|
*
|
|
* Fabric.Frontend is the sibling submodule under the parent Fabric repo.
|
|
*/
|
|
import { execSync } from 'node:child_process'
|
|
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
const DESKTOP = path.resolve(__dirname, '..')
|
|
const FRONTEND = path.resolve(DESKTOP, '..', 'Fabric.Frontend')
|
|
const SRC = path.join(FRONTEND, 'dist-desktop')
|
|
const DEST = path.join(DESKTOP, 'renderer')
|
|
|
|
if (!fs.existsSync(FRONTEND)) {
|
|
console.error(`[build-renderer] Fabric.Frontend not found at ${FRONTEND}`)
|
|
process.exit(1)
|
|
}
|
|
|
|
console.log('[build-renderer] building frontend (relative base)…')
|
|
execSync('npm install --no-audit --no-fund', { cwd: FRONTEND, stdio: 'inherit' })
|
|
execSync('npm run build:desktop', { cwd: FRONTEND, stdio: 'inherit' })
|
|
|
|
if (!fs.existsSync(path.join(SRC, 'index.html'))) {
|
|
console.error(`[build-renderer] expected ${SRC}/index.html after build`)
|
|
process.exit(1)
|
|
}
|
|
|
|
fs.rmSync(DEST, { recursive: true, force: true })
|
|
fs.cpSync(SRC, DEST, { recursive: true })
|
|
console.log(`[build-renderer] copied ${SRC} -> ${DEST}`)
|