Лицензия, редактор, пульт и сборка
- Main: license service, IPC, router; закрытие окон; yauzl закрытие zip (EMFILE), zipRead тест - Editor: стабильный projectState без мигания, логотип и меню, строки UI, LayoutShell overlay - Control: ластик для всех типов эффектов, затухание/нарастание музыки при смене сцены - Сборка: vite, build/dev scripts, obfuscate-main и build-env скрипты с тестами; package.json Made-with: Cursor
This commit is contained in:
+44
-12
@@ -5,39 +5,71 @@ import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { build } from 'esbuild';
|
||||
|
||||
import { resolveIsProduction, resolveObfuscateMain } from './build-env.mjs';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const root = path.resolve(__dirname, '..');
|
||||
|
||||
const isProd = resolveIsProduction();
|
||||
const obfuscateMain = resolveObfuscateMain();
|
||||
|
||||
/** Старые .map от dev-сборок не должны попадать в pack. */
|
||||
function removeStaleNodeBundleMaps() {
|
||||
for (const p of [
|
||||
path.join(root, 'dist/main/index.cjs.map'),
|
||||
path.join(root, 'dist/preload/index.cjs.map'),
|
||||
]) {
|
||||
if (fs.existsSync(p)) fs.unlinkSync(p);
|
||||
}
|
||||
}
|
||||
|
||||
function runViteBuild() {
|
||||
execFileSync('npx vite build', {
|
||||
const cmd = isProd ? 'npx vite build' : 'npx vite build --mode development';
|
||||
execFileSync(cmd, {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_ENV: isProd ? 'production' : 'development',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function buildNodeTargets() {
|
||||
await build({
|
||||
entryPoints: [path.join(root, 'app/main/index.ts')],
|
||||
outfile: path.join(root, 'dist/main/index.cjs'),
|
||||
if (isProd) removeStaleNodeBundleMaps();
|
||||
|
||||
const nodeEnvLiteral = JSON.stringify(isProd ? 'production' : 'development');
|
||||
const common = {
|
||||
platform: 'node',
|
||||
target: 'node22',
|
||||
format: 'cjs',
|
||||
bundle: true,
|
||||
sourcemap: true,
|
||||
minify: isProd,
|
||||
sourcemap: !isProd,
|
||||
external: ['electron'],
|
||||
});
|
||||
define: { 'process.env.NODE_ENV': nodeEnvLiteral },
|
||||
drop: isProd ? ['console', 'debugger'] : [],
|
||||
};
|
||||
|
||||
const mainOut = path.join(root, 'dist/main/index.cjs');
|
||||
|
||||
await build({
|
||||
...common,
|
||||
entryPoints: [path.join(root, 'app/main/index.ts')],
|
||||
outfile: mainOut,
|
||||
});
|
||||
|
||||
if (isProd && obfuscateMain) {
|
||||
const { obfuscateMainBundleFile } = await import('./obfuscate-main.mjs');
|
||||
obfuscateMainBundleFile(mainOut);
|
||||
}
|
||||
|
||||
await build({
|
||||
...common,
|
||||
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'],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user