Files
SodiumPet/scripts/dev.mjs
T

20 lines
663 B
JavaScript

import { spawn } from 'node:child_process'
import { fileURLToPath } from 'node:url'
import path from 'node:path'
const root = path.dirname(path.dirname(fileURLToPath(import.meta.url)))
const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx'
const vite = spawn(npx, ['vite', '--port', '5273'], { cwd: root, stdio: 'inherit' })
setTimeout(() => {
const env = { ...process.env, VITE_DEV_SERVER_URL: 'http://localhost:5273' }
const electron = spawn(npx, ['electron', '.'], { cwd: root, stdio: 'inherit', env })
electron.on('exit', (code) => {
vite.kill()
process.exit(code ?? 0)
})
}, 1500)
vite.on('exit', (code) => process.exit(code ?? 0))