import { defineConfig } from "vite"; import solid from "vite-plugin-solid"; import { copyFileSync, mkdirSync } from "fs"; import { resolve } from "path"; const copyPdfJsWorker = { name: "copy-pdfjs-worker", closeBundle() { mkdirSync("dist-mobile", { recursive: true }); copyFileSync( resolve("node_modules/pdfjs-dist/build/pdf.worker.min.mjs"), resolve("dist-mobile", "pdf.worker.min.mjs"), ); }, }; export default defineConfig({ plugins: [solid(), copyPdfJsWorker], base: "./", define: { __VERSION__: JSON.stringify(process.env.npm_package_version ?? "0.0.0"), // passkey.ts references this at module init via PASSKEY_CREATE_E2E_BYPASS. // Must be replaced at build time or the popup boot throws ReferenceError // and every sendMessage on Android sits in the shim queue forever. __PEACH_E2E_PASSKEYS__: JSON.stringify(false), }, build: { outDir: "dist-mobile", // The old input (src/popup/index.html) built a pre-Ring1 Capacitor-era // bundle; emptying the dir avoids a stale mix of that output with the // new src/mobile/entry.ts bundle. emptyOutDir: true, target: "esnext", rollupOptions: { // src/mobile/index.html (not src/popup/index.html) — the mobile shell // boots through src/mobile/entry.ts so the chrome shim installs before // any other module evaluates (§4.1). src/popup/** stays untouched. input: "src/mobile/index.html", }, }, });