1import tailwindcss from "@tailwindcss/vite";
2import react from "@vitejs/plugin-react";
3import rsc from "@vitejs/plugin-rsc";
4import { defineConfig } from "vite";
5
6// React Router RSC wired directly on @vitejs/plugin-rsc. Alchemy injects
7// its Cloudflare Vite plugin on top of this config at build and dev time,
8// so there is nothing Cloudflare-specific to add here.
9export default defineConfig({
10 plugins: [
11 tailwindcss(),
12 react(),
13 rsc({
14 serverHandler: false,
15 entries: {
16 client: "./react-router-vite/entry.browser.tsx",
17 ssr: "./react-router-vite/entry.ssr.tsx",
18 rsc: "./react-router-vite/entry.worker.tsx",
19 },
20 }),
21 ],
22 environments: {
23 // The Worker is the RSC environment.
24 rsc: {
25 build: {
26 rollupOptions: {
27 input: { "entry.worker": "./react-router-vite/entry.worker.tsx" },
28 },
29 },
30 },
31 // A second `ssr` input the Worker loads on demand via
32 // loadModule("ssr", "worker-ssr") — alongside the framework's `index`.
33 ssr: {
34 build: {
35 rollupOptions: {
36 input: { "worker-ssr": "./react-router-vite/worker-ssr.tsx" },
37 },
38 },
39 },
40 },
41 optimizeDeps: {
42 include: ["react-router", "react-router/internal/react-server-client"],
43 },
44});