-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
106 lines (104 loc) · 2.91 KB
/
Copy pathvite.config.ts
File metadata and controls
106 lines (104 loc) · 2.91 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { cloudflare } from "@cloudflare/vite-plugin";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import { decoVitePlugin } from "@decocms/tanstack/vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
import path from "path";
const srcDir = path.resolve(__dirname, "src");
export default defineConfig({
server: {
allowedHosts: [".decocdn.com", ".trycloudflare.com", ".preview-studio.decocms.com"],
// Shopify Storefront API is called server-side from loaders — no dev
// proxy is needed. Checkout happens on Shopify's hosted checkout (or
// the store's custom domain).
},
plugins: [
cloudflare({ viteEnvironment: { name: "ssr" } }),
tanstackStart({ server: { entry: "server" } }),
react({
babel: {
plugins: [
["babel-plugin-react-compiler", { target: "19" }],
],
},
}),
tailwindcss(),
decoVitePlugin(),
{
name: "site-manual-chunks",
config(_cfg, { command }) {
if (command !== "build") return;
return {
build: {
rollupOptions: {
output: {
manualChunks(id: string) {
if (id.includes("node_modules/react-dom") || id.includes("node_modules/react/"))
return "vendor-react";
if (id.includes("@tanstack/react-router") || id.includes("@tanstack/start"))
return "vendor-router";
if (id.includes("@tanstack/react-query")) return "vendor-query";
},
},
},
},
};
},
},
{
name: "deco-stub-meta-gen",
enforce: "pre" as const,
resolveId(id, importer, options) {
if (!options?.ssr && importer && id.includes("meta.gen")) {
return "\0stub:meta-gen";
}
},
load(id) {
if (id === "\0stub:meta-gen") {
return "export default {};";
}
},
},
],
build: {
sourcemap: "hidden",
rollupOptions: {
onLog(level, log, handler) {
if (
log.code === "PLUGIN_WARNING" &&
log.plugin === "vite:reporter" &&
log.message?.includes("dynamic import will not move module")
) {
return;
}
handler(level, log);
},
},
},
define: {
"process.env.DECO_SITE_NAME": JSON.stringify(
process.env.DECO_SITE_NAME || "storefront-tanstack"
),
},
esbuild: {
jsx: "automatic",
jsxImportSource: "react",
},
resolve: {
dedupe: [
"@tanstack/react-start",
"@tanstack/react-router",
"@tanstack/react-start-server",
"@tanstack/start-server-core",
"@tanstack/start-client-core",
"@tanstack/start-plugin-core",
"@tanstack/start-storage-context",
"react",
"react-dom",
],
alias: {
"~": srcDir,
},
},
});