vite.config.mobile.ts

1.6 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    __BUILD_TIME__: JSON.stringify(22      new Date().toLocaleTimeString([], {23        hour: "2-digit",24        minute: "2-digit",25        second: "2-digit",26      })27    ),28    __VERSION__: JSON.stringify(process.env.npm_package_version ?? "0.0.0"),29    // passkey.ts references this at module init via PASSKEY_CREATE_E2E_BYPASS.30    // Must be replaced at build time or the popup boot throws ReferenceError31    // and every sendMessage on Android sits in the shim queue forever.32    __PEACH_E2E_PASSKEYS__: JSON.stringify(false),33  },34  build: {35    outDir: "dist-mobile",36    // The old input (src/popup/index.html) built a pre-Ring1 Capacitor-era37    // bundle; emptying the dir avoids a stale mix of that output with the38    // new src/mobile/entry.ts bundle.39    emptyOutDir: true,40    target: "esnext",41    rollupOptions: {42      // src/mobile/index.html (not src/popup/index.html) — the mobile shell43      // boots through src/mobile/entry.ts so the chrome shim installs before44      // any other module evaluates (§4.1). src/popup/** stays untouched.45      input: "src/mobile/index.html",46    },47  },48});