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: { __BUILD_TIME__: JSON.stringify( new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit", }) ), __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", emptyOutDir: false, target: "esnext", rollupOptions: { input: "src/popup/index.html", }, }, });