batchCooking/apps/web/capacitor.config.ts
Nicolas ff36cefcde
Some checks failed
CI / lint (push) Failing after 1m59s
CI / build (push) Successful in 3m55s
CI / test (push) Has been cancelled
CI / intent-service-test (push) Has been cancelled
CI / e2e (push) Has been cancelled
feat(web): plomberie web pour la coquille Capacitor Android (#39 phase 2)
Tout ce qui est vérifiable en CI de la phase 2 du portage mobile. La
génération du projet natif (`npx cap add android`), le build de l'APK et
le test sur appareil restent une étape manuelle (pas d'Android Studio ici)
— cf. le corps de l'issue #39.

- Dépendances : `@capacitor/core`, `@capacitor/android`,
  `@capacitor/preferences` (+ `@capacitor/cli` en dev), toutes en 8.5.x.
- `capacitor.config.ts` : `appId` `fr.kyuno.batchcooking`, `webDir: "dist"`.
- `apps/web/src/api/capacitor-token-store.ts` : implémentation `TokenStore`
  adossée à `@capacitor/preferences`, branchée via `setTokenStore()` (le
  point d'injection posé en phase 1). Importée dynamiquement dans
  `main.tsx` uniquement quand `Capacitor.isNativePlatform()` — le bundle
  web ne charge jamais `@capacitor/preferences` (vérifié : chunk séparé de
  0,5 ko jamais requis côté navigateur).
- `main.tsx` : `HashRouter` en natif (le bundle packagé sert `dist/`
  depuis l'origine locale de la WebView, sans réécriture des liens
  profonds vers `index.html`), `BrowserRouter` inchangé sur le web ;
  bootstrap async pour poser le token store avant le premier rendu.
- `build:capacitor` (`vite build --mode capacitor`) + `.env.capacitor.example` :
  le build packagé a besoin de l'URL absolue de l'API en dur (pas de
  "même origine que la page" possible).

Vérifié : `pnpm build` + `pnpm lint` verts ; Cypress smoke/layout/sidebar
14/14 en local (le refactor du bootstrap et le choix de routeur ne
cassent rien côté web).

Refs #39
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-06 03:56:15 +02:00

22 lines
855 B
TypeScript

import type { CapacitorConfig } from "@capacitor/cli";
/**
* Capacitor project config — read by the `@capacitor/cli` tooling
* (`npx cap add android`, `npx cap sync`, `npx cap run android`), never
* bundled into the web app. See issue #39.
*
* `webDir` points at Vite's build output: the packaged app ships that
* folder inside the APK and serves it from the WebView's own local origin
* (`https://localhost` on Android), with no dev server. Build it for the
* native target with `pnpm --filter web build:capacitor`, which bakes in
* the public API URL (see `.env.capacitor.example`) — a packaged bundle
* can't use the relative-URL "same origin as the page" default the web
* build relies on.
*/
const config: CapacitorConfig = {
appId: "fr.kyuno.batchcooking",
appName: "Batch Cooking",
webDir: "dist",
};
export default config;