forked from Weaverse/weaverse
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
75 lines (72 loc) · 1.94 KB
/
Copy pathvite.config.ts
File metadata and controls
75 lines (72 loc) · 1.94 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
73
74
75
import { reactRouter } from "@react-router/dev/vite";
import { hydrogen } from "@shopify/hydrogen/vite";
import { oxygen } from "@shopify/mini-oxygen/vite";
import tailwindcss from "@tailwindcss/vite";
import { fileURLToPath } from "node:url";
import type { Plugin } from "vite";
import { defineConfig } from "vite";
// The Oxygen worker inlines dynamic imports, so replace browser-only media
// packages during SSR to avoid shipping their player stacks in the worker.
const SSR_STUBBED_MODULES = new Set(["react-player"]);
function ssrStubClientOnlyModules(): Plugin {
return {
name: "ssr-stub-client-only-modules",
enforce: "pre",
resolveId(id, _importer, options) {
if (options?.ssr && SSR_STUBBED_MODULES.has(id)) {
return fileURLToPath(
new URL("./app/utils/ssr-client-only-stub.ts", import.meta.url),
);
}
return null;
},
};
}
export default defineConfig(({ isSsrBuild }) => ({
plugins: [
hydrogen(),
oxygen(),
reactRouter(),
tailwindcss(),
ssrStubClientOnlyModules(),
],
resolve: {
tsconfigPaths: true,
},
build: {
// Allow a strict Content-Security-Policy
// without inlining assets as base64:
assetsInlineLimit: 0,
...(!isSsrBuild && {
rollupOptions: {
output: {
manualChunks(id: string) {
// Keep lazy react-player chunks separate from eager media code.
if (id.includes("swiper")) return "vendor-media";
if (id.includes("react-share")) return "vendor-social";
if (id.includes("@radix-ui")) return "vendor-radix";
},
},
},
}),
},
server: {
warmup: {
clientFiles: [
"./app/routes/**/*",
"./app/sections/**/*",
"./app/components/**/*",
],
},
},
ssr: {
optimizeDeps: {
include: [
"@radix-ui/react-primitive",
"jsonp",
"classnames",
"react-share",
],
},
},
}));