vite.config.mobile.ts

1.4 KB · raw

1import { defineConfig } from "vite";2import solid from "vite-plugin-solid";3import { copyFileSync, mkdirSync } from "fs";4import { resolve } from "path";56const copyPdfJsWorker = {7  name: "copy-pdfjs-worker",8  closeBundle() {9    mkdirSync("dist-mobile", { recursive: true });10    copyFileSync(11      resolve("node_modules/pdfjs-dist/build/pdf.worker.min.mjs"),12      resolve("dist-mobile", "pdf.worker.min.mjs"),13    );14  },15};1617export default defineConfig({18  plugins: [solid(), copyPdfJsWorker],19  base: "./",20  define: {21    __VERSION__: JSON.stringify(process.env.npm_package_version ?? "0.0.0"),22    // passkey.ts references this at module init via PASSKEY_CREATE_E2E_BYPASS.23    // Must be replaced at build time or the popup boot throws ReferenceError24    // and every sendMessage on Android sits in the shim queue forever.25    __PEACH_E2E_PASSKEYS__: JSON.stringify(false),26  },27  build: {28    outDir: "dist-mobile",29    // The old input (src/popup/index.html) built a pre-Ring1 Capacitor-era30    // bundle; emptying the dir avoids a stale mix of that output with the31    // new src/mobile/entry.ts bundle.32    emptyOutDir: true,33    target: "esnext",34    rollupOptions: {35      // src/mobile/index.html (not src/popup/index.html) — the mobile shell36      // boots through src/mobile/entry.ts so the chrome shim installs before37      // any other module evaluates (§4.1). src/popup/** stays untouched.38      input: "src/mobile/index.html",39    },40  },41});