The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | /** |
| 2 | * A REAL user-owned Vite config, exactly like a normal SvelteKit v3 project: |
| 3 | * the user registers `sveltekit()` here themselves, and |
| 4 | * `@alchemy.run/frontend-frameworks/sveltekit` must load this file natively and inject its |
| 5 | * deploy-target adapter into THIS `sveltekit(...)` instance rather than |
| 6 | * constructing a second one (the user-config principle). |
| 7 | * |
| 8 | * NOTE: kit v3 HARD-ERRORS if a `svelte.config.js`/`.ts` exists at the |
| 9 | * project root ("svelte.config.js is no longer used") — ALL configuration, |
| 10 | * including Svelte `preprocess`/`compilerOptions`, lives in this |
| 11 | * `sveltekit(...)` call. The user-config proof: |
| 12 | * |
| 13 | * - `preprocess: [markerPreprocessor]` — rewrites the literal |
| 14 | * `__SVELTE_CONFIG_MARKER__` (rendered by the home page) to |
| 15 | * `svelte-config-loaded`; the smoke test asserts the replaced value, which |
| 16 | * only appears if this file's svelte configuration is honored. |
| 17 | */ |
| 18 | import { sveltekit } from "@sveltejs/kit/vite"; |
| 19 | import { defineConfig } from "vite"; |
| 20 | |
| 21 | const markerPreprocessor = { |
| 22 | name: "fixture-user-preprocessor", |
| 23 | markup: ({ content }: { content: string }) => { |
| 24 | if (!content.includes("__SVELTE_CONFIG_MARKER__")) return undefined; |
| 25 | return { |
| 26 | code: content.replaceAll("__SVELTE_CONFIG_MARKER__", "svelte-config-loaded"), |
| 27 | }; |
| 28 | }, |
| 29 | }; |
| 30 | |
| 31 | export default defineConfig({ |
| 32 | plugins: [ |
| 33 | sveltekit({ |
| 34 | preprocess: [markerPreprocessor], |
| 35 | }), |
| 36 | ], |
| 37 | }); |