Phase 1 step 1 of VNCprodbuild: electron/main.ts boots the same Next.js "standalone" server artifact the Dockerfile already produces (next.config.ts's output: "standalone") as a child process on a random localhost port, then opens a BrowserWindow at it. electron/preload.ts is a contextBridge stub (window.vnc.isElectron) for now. scripts/assemble-standalone.mjs copies public/ and .next/static into .next/standalone, mirroring what the Dockerfile does by hand, since `next build` deliberately leaves both out of the standalone output. scripts/build-electron.mjs bundles main.ts/preload.ts to CommonJS via esbuild (already a devDependency). New npm scripts: build:standalone, build:electron, electron:dev. electron-builder.config.js is intentionally minimal - no signing, no platform targets yet, just enough to prove the concept end to end. Also fixes a pre-existing repo-wide lint gap: vnc/plugins/smime is an independent sub-package (own package.json/esbuild build, browser-only globals) that was never added to eslint's ignores alongside repos:: and examples/**, so `npm run lint` - and the husky pre-commit hook - was failing on every commit regardless of what changed. Excluded it the same way those are, and added node globals for scripts/**/*.mjs so the new build helpers above lint cleanly too. Verified manually: npm run build:standalone && npm run build:electron && electron . boots the server and opens a window with no errors.
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
#!/usr/bin/env node
|
|
// Bundles electron/main.ts and electron/preload.ts into dist-electron/*.js.
|
|
// Uses esbuild (already a devDependency for the admin plugin dev-bundler,
|
|
// lib/admin/plugin-dev.ts) rather than pulling in ts-node/tsx - the output
|
|
// is plain CommonJS, so the packaged app needs no separate TS runtime.
|
|
import { build } from "esbuild";
|
|
import { fileURLToPath } from "node:url";
|
|
import path from "node:path";
|
|
|
|
const rootDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
|
|
const shared = {
|
|
bundle: true,
|
|
platform: "node",
|
|
target: "node22",
|
|
format: "cjs",
|
|
sourcemap: true,
|
|
// `electron` is provided by the Electron runtime itself; `electron-updater`
|
|
// stays external so electron-builder ships it from node_modules as a
|
|
// normal production dependency instead of us re-bundling its native-ish
|
|
// internals (see electron-builder.config.js's file collection).
|
|
external: ["electron", "electron-updater"],
|
|
logLevel: "info",
|
|
};
|
|
|
|
await build({
|
|
...shared,
|
|
entryPoints: [path.join(rootDir, "electron/main.ts")],
|
|
outfile: path.join(rootDir, "dist-electron/main.js"),
|
|
});
|
|
|
|
await build({
|
|
...shared,
|
|
entryPoints: [path.join(rootDir, "electron/preload.ts")],
|
|
outfile: path.join(rootDir, "dist-electron/preload.js"),
|
|
});
|