45105cd069
Auto-seeds 10 presets on first launch; visual designer with palette, drag, resize, and bricks CRUD. Co-authored-by: Cursor <cursoragent@cursor.com>
59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
import { build } from 'esbuild';
|
|
import { spawn } from 'node:child_process';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import fs from 'node:fs';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const root = path.resolve(__dirname, '..');
|
|
|
|
async function buildMain() {
|
|
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'],
|
|
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,
|
|
});
|
|
}
|
|
|
|
function electronPath() {
|
|
const name = process.platform === 'win32' ? 'electron.cmd' : 'electron';
|
|
const bin = path.join(root, 'node_modules', '.bin', name);
|
|
if (fs.existsSync(bin)) return bin;
|
|
return path.join(root, 'node_modules', 'electron', 'cli.js');
|
|
}
|
|
|
|
await buildMain();
|
|
|
|
const vite = spawn(
|
|
process.platform === 'win32' ? 'npx.cmd' : 'npx',
|
|
['vite', '--config', 'vite.config.ts'],
|
|
{ cwd: root, stdio: 'inherit', shell: true },
|
|
);
|
|
|
|
await new Promise((r) => setTimeout(r, 2000));
|
|
|
|
const elec = spawn(electronPath(), ['.'], {
|
|
cwd: root,
|
|
stdio: 'inherit',
|
|
shell: true,
|
|
env: { ...process.env, VITE_DEV_SERVER_URL: 'http://localhost:5174' },
|
|
});
|
|
|
|
elec.on('exit', (code) => {
|
|
vite.kill();
|
|
process.exit(code ?? 0);
|
|
});
|