Files
Showy/tauri/scripts/prepare-sidecar.mjs
X4Lo 3144bd96c9 Add Tauri v2 desktop app alongside Electron
- New tauri/ project: frameless 1280x800 window, loads the Vite dev
  server in dev and tauri/frontend_build in release builds.
- Starts the backend on launch (node server.js in dev, pkg backend.exe
  sidecar in release) and stops it on exit through a Windows job
  object; reuses a backend already listening on port 4000.
- Custom title bar works in Tauri (minimize, maximize, close, drag
  region) with the matching window capabilities.
- react_frontend: dev:tauri / build:tauri scripts, shared platform
  flags so Electron and Tauri builds both use the local API and hash
  router. Web and Electron builds are unchanged.
- tauri/README.md: prerequisites, dev, build, and gaps vs Electron.
2026-11-05 18:27:40 +00:00

37 lines
1.3 KiB
JavaScript

// Copies the pkg-packaged backend (dist/backend/backend.exe) into
// src-tauri/binaries/ under the name Tauri expects for an external binary:
// backend-<rust target triple>[.exe].
//
// Build the backend first: cd backend && npm run package
import { execSync } from "node:child_process";
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const here = dirname(fileURLToPath(import.meta.url));
const repoRoot = resolve(here, "..", "..");
const ext = process.platform === "win32" ? ".exe" : "";
const source = join(repoRoot, "dist", "backend", `backend${ext}`);
const triple = execSync("rustc -vV", { encoding: "utf8" })
.split("\n")
.find((line) => line.startsWith("host:"))
?.slice("host:".length)
.trim();
if (!triple) {
console.error("Could not read the Rust host triple from `rustc -vV`.");
process.exit(1);
}
if (!existsSync(source)) {
console.error(`Backend executable not found: ${source}`);
console.error("Build it first: cd backend && npm run package");
process.exit(1);
}
const targetDir = resolve(here, "..", "src-tauri", "binaries");
mkdirSync(targetDir, { recursive: true });
const target = join(targetDir, `backend-${triple}${ext}`);
copyFileSync(source, target);
console.log(`Copied ${source} -> ${target}`);