| 1 | # aws-router |
| 2 | |
| 3 | Two Vite sites behind one shared `AWS.Website.Router`, mounted on different |
| 4 | paths: |
| 5 | |
| 6 | | Path | Site | |
| 7 | | --------- | ----------- | |
| 8 | | `/` | `apps/web` | |
| 9 | | `/docs/*` | `apps/docs` | |
| 10 | |
| 11 | ## Local |
| 12 | |
| 13 | ```sh |
| 14 | pnpm dev |
| 15 | ``` |
| 16 | |
| 17 | `alchemy dev` runs each site's own Vite dev server (HMR included) and serves |
| 18 | the Router from a locally emulated CloudFront on its own port: |
| 19 | |
| 20 | ``` |
| 21 | url http://localhost:9500 |
| 22 | web http://localhost:5173 |
| 23 | docs http://localhost:5174 |
| 24 | ``` |
| 25 | |
| 26 | Open the `url` — `/` and `/docs/` route to the two dev servers through the |
| 27 | emulated edge, running the same CloudFront Function a deploy would. Editing |
| 28 | either app updates instantly; no redeploy, no invalidation. |
| 29 | |
| 30 | Requires Docker: the emulator runs as a container that `alchemy dev` starts |
| 31 | for you. |
| 32 | |
| 33 | ## Deploy |
| 34 | |
| 35 | ```sh |
| 36 | pnpm deploy |
| 37 | ``` |
| 38 | |
| 39 | Creates a real CloudFront distribution, uploads each site to S3, and serves |
| 40 | both from the same front door. `pnpm destroy` tears it down. |
| 41 | |
| 42 | ## Notes |
| 43 | |
| 44 | The path prefix is not stripped: a site mounted at `/docs` is addressed as |
| 45 | `/docs/...` at the edge, so `apps/docs` sets Vite's `base` to `/docs/` to |
| 46 | match. `apps/web` is at the root and needs no `base`. |
| 47 | |
| 48 | Nothing in `alchemy.run.ts` is dev-specific — the same resource graph is |
| 49 | declared in both modes. |