| 1 | import * as Alchemy from "alchemy"; |
| 2 | import * as Fly from "alchemy/Fly"; |
| 3 | import * as Output from "alchemy/Output"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import Api from "./src/api.ts"; |
| 6 | import { Db } from "./src/shared.ts"; |
| 7 | |
| 8 | export default Alchemy.Stack( |
| 9 | "FlyWebsiteViteExample", |
| 10 | { |
| 11 | providers: Fly.providers(), |
| 12 | state: Alchemy.localState(), |
| 13 | }, |
| 14 | Effect.gen(function* () { |
| 15 | const db = yield* Db; |
| 16 | const api = yield* Api; |
| 17 | const web = yield* Fly.Website.Vite("Web", { |
| 18 | env: { |
| 19 | VITE_API_URL: Output.map(api.url, (url) => url ?? ""), |
| 20 | }, |
| 21 | memo: { |
| 22 | include: ["index.html", "src/**", "package.json", "vite.config.ts"], |
| 23 | }, |
| 24 | }); |
| 25 | |
| 26 | return { |
| 27 | url: web.url, |
| 28 | apiUrl: api.url, |
| 29 | appName: web.app?.appName, |
| 30 | apiAppName: api.appName, |
| 31 | clusterId: db.clusterId, |
| 32 | }; |
| 33 | }), |
| 34 | ); |