-
-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathvite.config.ts
More file actions
72 lines (66 loc) · 2.27 KB
/
vite.config.ts
File metadata and controls
72 lines (66 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import react from '@vitejs/plugin-react'
import rsc from '@vitejs/plugin-rsc'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
rsc({
// `entries` option is only a shorthand for specifying each `rollupOptions.input` below
// > entries: { rsc, ssr, client },
//
// by default, the plugin setup request handler based on `default export` of `rsc` environment `rollupOptions.input.index`.
// This can be disabled when setting up own server handler e.g. `@cloudflare/vite-plugin`.
// > serverHandler: false
}),
// use any of react plugins https://github.com/vitejs/vite-plugin-react
// to enable client component HMR
react(),
// use https://github.com/antfu-collective/vite-plugin-inspect
// to understand internal transforms required for RSC.
// import("vite-plugin-inspect").then(m => m.default()),
],
// specify entry point for each environment.
// (currently the plugin assumes `rollupOptions.input.index` for some features.)
environments: {
// `rsc` environment loads modules with `react-server` condition.
// this environment is responsible for:
// - RSC stream serialization (React VDOM -> RSC stream)
// - server functions handling
rsc: {
build: {
rollupOptions: {
input: {
index: './src/framework/entry.rsc.tsx',
},
},
},
},
// `ssr` environment loads modules without `react-server` condition.
// this environment is responsible for:
// - RSC stream deserialization (RSC stream -> React VDOM)
// - traditional SSR (React VDOM -> HTML string/stream)
ssr: {
build: {
rollupOptions: {
input: {
index: './src/framework/entry.ssr.tsx',
},
},
},
},
// client environment is used for hydration and client-side rendering
// this environment is responsible for:
// - RSC stream deserialization (RSC stream -> React VDOM)
// - traditional CSR (React VDOM -> Browser DOM tree mount/hydration)
// - refetch and re-render RSC
// - calling server functions
client: {
build: {
rollupOptions: {
input: {
index: './src/framework/entry.browser.tsx',
},
},
},
},
},
})