vite.config.mobile.ts

1.1 KB · raw

1import { defineConfig } from "vite";2import solidPlugin from "vite-plugin-solid";34export default defineConfig({5  plugins: [6    solidPlugin(),7    {8      name: "mobile-body-class",9      transformIndexHtml(html) {10        return html.replace("<body>", '<body class="peach-mobile">');11      },12    },13  ],14  build: {15    outDir: "dist-mobile",16    emptyOutDir: false,17    target: "esnext",18    rollupOptions: {19      input: "src/popup/index.html",20      plugins: [21        {22          // Mobile has no extension background, but shared background modules23          // still use chrome.storage/tabs/alarms. Import the Capacitor-backed24          // shim before the popup app graph can load those modules.25          apply: "build",26          enforce: "pre",27          transform(code, id) {28            if (id.includes("src/popup/index")) {29              return {30                code: `import "../shared/chrome-shim";\n${code}`,31                map: null,32              };33            }34            return null;35          },36        },37      ],38    },39  },40  define: {41    "import.meta.env.PEACH_PLATFORM": JSON.stringify("android"),42  },43});