51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
import { spawn } from 'child_process';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname, join } from 'path';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const ROOT = join(__dirname, '..');
|
|
|
|
async function build() {
|
|
try {
|
|
// Build Vite/React
|
|
console.log('Building Vite/React...');
|
|
await spawnAsync('npm', ['run', 'build:vite']);
|
|
|
|
// Build main process
|
|
console.log('Building main process...');
|
|
await spawnAsync('tsc', ['-p', 'electron/tsconfig.json']);
|
|
|
|
// Build preload script
|
|
console.log('Building preload script...');
|
|
await spawnAsync('tsc', ['-p', 'electron/tsconfig.preload.json']);
|
|
|
|
console.log('Build complete!');
|
|
} catch (error) {
|
|
console.error('Build failed:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
function spawnAsync(command, args) {
|
|
return new Promise((resolve, reject) => {
|
|
const childProcess = spawn(command, args, {
|
|
stdio: 'inherit',
|
|
shell: true,
|
|
});
|
|
|
|
childProcess.on('close', (code) => {
|
|
if (code === 0) {
|
|
resolve();
|
|
} else {
|
|
reject(new Error(`Process exited with code ${code}`));
|
|
}
|
|
});
|
|
|
|
childProcess.on('error', (error) => {
|
|
reject(error);
|
|
});
|
|
});
|
|
}
|
|
|
|
build();
|