vite.config.ts

1.4 KB · raw

1import { defineConfig } from "vite";2import solidPlugin from "vite-plugin-solid";3import { crx } from "@crxjs/vite-plugin";4import { readFileSync } from "fs";56const target = process.env.BUILD_TARGET || "chrome";7const manifestPath = target === "firefox" ? "./manifest.firefox.json" : "./manifest.json";8const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));9const passkeyE2E = process.env.PEACH_E2E_PASSKEYS === "1";1011export default defineConfig({12  plugins: [solidPlugin(), crx({ manifest, browser: target === "firefox" ? "firefox" : "chrome" })],13  base: "./",14  define: {15    __PEACH_E2E_PASSKEYS__: JSON.stringify(passkeyE2E),16  },17  build: {18    outDir: target === "firefox" ? "dist-firefox" : "dist-chrome",19    // emptyOutDir must stay false. When true, Vite tries to remove the20    // contents of the outDir before each build, which throws EPERM on FUSE21    // and some mounted filesystems and aborts the whole build. Overwriting22    // in place works everywhere.23    emptyOutDir: false,24    target: "esnext",25    rollupOptions: {26      output: {27        manualChunks(id) {28          if (id.includes("node_modules/solid-js")) return "vendor-solid";29          if (id.includes("node_modules/otpauth")) return "vendor-otp";30          if (id.includes("node_modules/papaparse")) return "vendor-parse";31          if (id.includes("node_modules/qrcode")) return "vendor-qr";32        },33      },34    },35  },36});