-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
63 lines (59 loc) · 1.58 KB
/
vite.config.ts
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
import { defineConfig, UserConfig } from "vite";
import viteReact from "@vitejs/plugin-react";
import { visualizer } from "rollup-plugin-visualizer";
import { granularChunk } from "./src/framework/plugins/granular-chunk";
import { serverComponents } from "./src/framework/plugins/server-components";
function extendConfig<C extends UserConfig>(config: C): C {
return config;
}
export default defineConfig((env) => {
const prod = env.mode === "production";
const config = extendConfig({
plugins: [
viteReact(),
serverComponents(),
granularChunk({
react: [
"react",
"react-dom",
"react-server-dom-webpack",
"scheduler",
"object-assign",
],
}),
],
ssr: {
external:
env.command !== "build"
? ["react-server-dom-webpack/writer.node.server"]
: undefined,
noExternal: env.command !== "serve",
target: "webworker",
},
resolve: {
alias: [
{ find: "stream", replacement: "/aliases/stream" },
{
find: "react-dom/server",
replacement: "/aliases/react-dom-server.cjs",
},
],
},
build: {
minify: prod,
sourcemap: true,
rollupOptions: {
plugins: [
/^yes|true$/i.test(process.env.ANALYZE) &&
visualizer({
open: true,
filename: "dist/stats.html",
gzipSize: true,
brotliSize: true,
}),
].filter(<T>(x: T | false): x is T => x !== false),
},
},
});
return config;
});