The best way to control Claude Code, Codex and more from any computer or phone

main
ts 60 lines 1.96 KB
Raw
1 /**
2 * A REAL user-owned Vite config, exactly like a normal SvelteKit v3 project:
3 * `sveltekit()` is registered here by the user (kit v3 has no
4 * `svelte.config.js` — all kit options live in this call), alongside a user
5 * Vite plugin. `@alchemy.run/frontend-frameworks/sveltekit` must load this file natively and
6 * inject its deploy-target adapter into THIS `sveltekit(...)` instance rather
7 * than constructing a second one.
8 *
9 * The suite proves the file is honored end-to-end (`/api/user-config`, live
10 * and dev):
11 *
12 * - `version: { name: ... }` — a user kit option observable at runtime via
13 * `$app/env`'s `version`; it only appears if the user's `sveltekit()`
14 * call is the one that runs.
15 * - `fixtureMarkerPlugin` — a user Vite plugin whose virtual module is
16 * observable in the build output.
17 * - `adapter: userDeclaredAdapter` — a user-declared adapter that THROWS if
18 * it ever runs: the integration must replace it (with a warning) with the
19 * deploy target's adapter, so a green build is proof of the override.
20 */
21 import type { Adapter } from "@sveltejs/kit";
22 import { sveltekit } from "@sveltejs/kit/vite";
23 import type { Plugin } from "vite";
24 import { defineConfig } from "vite";
25
26 const VIRTUAL_ID = "virtual:fixture-marker";
27 const RESOLVED_ID = `\0${VIRTUAL_ID}`;
28
29 const fixtureMarkerPlugin = (): Plugin => ({
30 name: "fixture-user-vite-plugin",
31 resolveId(id) {
32 if (id === VIRTUAL_ID) {
33 return RESOLVED_ID;
34 }
35 },
36 load(id) {
37 if (id === RESOLVED_ID) {
38 return `export const marker = "user-vite-plugin-active";`;
39 }
40 },
41 });
42
43 const userDeclaredAdapter: Adapter = {
44 name: "fixture-user-adapter",
45 adapt() {
46 throw new Error(
47 "fixture-user-adapter ran — the integration failed to inject the deploy target's adapter",
48 );
49 },
50 };
51
52 export default defineConfig({
53 plugins: [
54 fixtureMarkerPlugin(),
55 sveltekit({
56 adapter: userDeclaredAdapter,
57 version: { name: "fixture-user-version" },
58 }),
59 ],
60 });