d1f180ee0a
Offline Electron app seeds 10 system presets, supports create-from-scratch designer with palette/drag/resize/bricks, and exports .ttrpg-system.json for the player. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
import { build } from 'esbuild';
|
|
import { spawn } from 'node:child_process';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const root = path.resolve(__dirname, '..');
|
|
|
|
await build({
|
|
entryPoints: [path.join(root, 'app/main/index.ts')],
|
|
bundle: true,
|
|
platform: 'node',
|
|
format: 'cjs',
|
|
outfile: path.join(root, 'dist/main/index.cjs'),
|
|
external: ['electron', 'better-sqlite3'],
|
|
sourcemap: true,
|
|
});
|
|
|
|
await build({
|
|
entryPoints: [path.join(root, 'app/preload/index.ts')],
|
|
bundle: true,
|
|
platform: 'node',
|
|
format: 'cjs',
|
|
outfile: path.join(root, 'dist/preload/index.cjs'),
|
|
external: ['electron'],
|
|
sourcemap: true,
|
|
});
|
|
|
|
await new Promise((resolve, reject) => {
|
|
const p = spawn(
|
|
process.platform === 'win32' ? 'npx.cmd' : 'npx',
|
|
['vite', 'build', '--config', 'vite.config.ts'],
|
|
{ cwd: root, stdio: 'inherit', shell: true },
|
|
);
|
|
p.on('exit', (code) => (code === 0 ? resolve() : reject(new Error(`vite exit ${code}`))));
|
|
});
|