-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
126 lines (121 loc) · 3.39 KB
/
vite.config.ts
File metadata and controls
126 lines (121 loc) · 3.39 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import type { LoggingFunction, RollupLog } from "rollup";
import tailwindcss from "@tailwindcss/vite";
import { devtools } from "@tanstack/devtools-vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import react from "@vitejs/plugin-react";
import mdx from "fumadocs-mdx/vite";
import { nitro } from "nitro/vite";
import { fileURLToPath } from "node:url";
import { defineConfig } from "vite";
import svgr from "vite-plugin-svgr";
import tsConfigPaths from "vite-tsconfig-paths";
import { deploymentChangelogPlugin } from "./tools/source-plugins/deployment-changelog-plugin";
import { tanstackDevStylesBasePathPlugin } from "./tools/source-plugins/tanstack-dev-styles-base-path";
const BASE_PATH = "/graphql/hive";
const NITRO_PRESET = process.env["VERCEL"] ? "vercel" : "cloudflare-module";
const CLOUDFLARE_ENTRY = fileURLToPath(
new URL("src/server/cloudflare-entry.ts", import.meta.url),
);
export default defineConfig(async ({ command }) => ({
base: BASE_PATH,
build: {
rollupOptions: {
onwarn(warning: RollupLog, defaultHandler: LoggingFunction) {
if (warning.code === "MODULE_LEVEL_DIRECTIVE") return;
defaultHandler(warning);
},
},
},
define: {
BASE_PATH: JSON.stringify(BASE_PATH),
},
plugins: [
command === "serve" && !process.env["CI"] && devtools(),
command === "serve" && tanstackDevStylesBasePathPlugin(BASE_PATH),
deploymentChangelogPlugin(),
nitro({
baseURL: BASE_PATH,
cloudflare:
NITRO_PRESET === "cloudflare-module"
? {
wrangler: {
assets: {
html_handling: "drop-trailing-slash",
run_worker_first: true,
},
},
}
: undefined,
entry:
NITRO_PRESET === "cloudflare-module" ? CLOUDFLARE_ENTRY : undefined,
prerender: {
ignore: [/[?&]utm_/],
},
preset: NITRO_PRESET,
routeRules: await import("./redirects").then((m) => m.routeRules),
}),
mdx(await import("./source.config")),
tailwindcss(),
svgr({
include: "**/*.svg?svgr",
svgrOptions: {
svgoConfig: {
plugins: [
{
name: "preset-default",
params: {
overrides: {
minifyStyles: false,
removeTitle: false,
removeViewBox: false,
},
},
},
"removeXMLNS",
"removeXlink",
"prefixIds",
],
},
},
}),
tsConfigPaths({
projects: ["./tsconfig.json"],
}),
tanstackStart({
pages: [{ path: "/api/search" }],
prerender: {
crawlLinks: true,
enabled: true,
retryCount: 10,
retryDelay: 1000,
},
sitemap: {
enabled: true,
host: "https://the-guild.dev",
},
spa: {
enabled: true,
prerender: {
crawlLinks: true,
enabled: true,
},
},
}),
react(),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("src", import.meta.url)),
"@hive/design-system": fileURLToPath(
new URL("../design-system/src", import.meta.url),
),
},
},
server: {
// Vite will increment the port if 1440 is taken.
port: 1440,
},
ssr: {
noExternal: ["@hive/design-system", "tailwind-merge"],
},
}));