DNDGamePlayer: Electron редактор сцен, презентация, упаковка electron-builder
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { build } from 'esbuild';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const root = path.resolve(__dirname, '..');
|
||||
|
||||
function runViteBuild() {
|
||||
execFileSync('npx vite build', {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
});
|
||||
}
|
||||
|
||||
async function buildNodeTargets() {
|
||||
await build({
|
||||
entryPoints: [path.join(root, 'app/main/index.ts')],
|
||||
outfile: path.join(root, 'dist/main/index.cjs'),
|
||||
platform: 'node',
|
||||
target: 'node22',
|
||||
format: 'cjs',
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
external: ['electron'],
|
||||
});
|
||||
|
||||
await build({
|
||||
entryPoints: [path.join(root, 'app/preload/index.ts')],
|
||||
outfile: path.join(root, 'dist/preload/index.cjs'),
|
||||
platform: 'node',
|
||||
target: 'node22',
|
||||
format: 'cjs',
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
external: ['electron'],
|
||||
});
|
||||
}
|
||||
|
||||
await buildNodeTargets();
|
||||
execFileSync('node', [path.join(root, 'scripts', 'gen-window-icon.mjs')], {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
runViteBuild();
|
||||
Reference in New Issue
Block a user