1import type { Plugin } from "vite";
2import { defineConfig } from "waku/config";
3
4/**
5 * Real user config file, loaded NATIVELY by the integration (the same
6 * `vite.runnerImport("/waku.config")` semantics as waku's own CLI — see
7 * packages/frontend-frameworks/src/waku/Waku.ts `loadUserConfigFile`). Both settings here are
8 * user-observable and only work if this file is honored:
9 *
10 * - `rscBase` moves waku's RSC endpoint/payload base from the default `RSC`
11 * to `custom-rsc` (asserted against the SSG payload path in the smoke
12 * test).
13 * - the user vite plugin serves a virtual module imported by
14 * `src/pages/config-marker.tsx` — if the file were replaced instead of
15 * merged, the import would not resolve and build/dev would fail outright.
16 */
17
18export const USER_CONFIG_MARKER = "hello-from-waku-config";
19
20const VIRTUAL_ID = "virtual:fixtures-waku/user-config-marker";
21const RESOLVED_VIRTUAL_ID = `\0${VIRTUAL_ID}`;
22
23const userConfigMarkerPlugin = (): Plugin => ({
24 name: "fixtures-waku:user-config-marker",
25 resolveId(id) {
26 if (id === VIRTUAL_ID) {
27 return RESOLVED_VIRTUAL_ID;
28 }
29 return;
30 },
31 load(id) {
32 if (id === RESOLVED_VIRTUAL_ID) {
33 return `export const marker = ${JSON.stringify(USER_CONFIG_MARKER)};`;
34 }
35 return;
36 },
37});
38
39export default defineConfig({
40 rscBase: "custom-rsc",
41 vite: {
42 plugins: [userConfigMarkerPlugin()],
43 },
44});