-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
105 lines (101 loc) · 2.98 KB
/
vite.config.ts
File metadata and controls
105 lines (101 loc) · 2.98 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
import tailwindcss from "@tailwindcss/vite";
import { devtools } from "@tanstack/devtools-vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import viteReact from "@vitejs/plugin-react";
import { nitro } from "nitro/vite";
import { defineConfig } from "vite";
import type { Plugin } from "vite";
import type { IncomingMessage, ServerResponse } from "node:http";
import viteTsConfigPaths from "vite-tsconfig-paths";
// Custom Cache-Control headers for the public embed script so updates
// propagate quickly to embedders without requiring a versioned URL.
const setEmbedHeader = (
req: IncomingMessage,
res: ServerResponse,
next: (err?: unknown) => void,
) => {
if (req.url?.startsWith("/embed/popup.js")) {
res.setHeader("Cache-Control", "public, max-age=300, must-revalidate");
}
next();
};
const embedCacheHeadersPlugin = (): Plugin => ({
name: "embed-cache-headers",
configureServer(server) {
server.middlewares.use(setEmbedHeader);
},
configurePreviewServer(server) {
server.middlewares.use(setEmbedHeader);
},
});
const config = defineConfig({
plugins: [
embedCacheHeadersPlugin(),
devtools({
editor: {
name: "Cursor",
open: async (path, lineNumber, columnNumber) => {
const { exec } = await import("node:child_process");
exec(
// or windsurf/cursor/webstorm/cursor/cursor
`cursor -g "${path.replaceAll("$", "\\$")}${lineNumber ? `:${lineNumber}` : ""}${columnNumber ? `:${columnNumber}` : ""}"`,
);
},
},
// editor: {
// name: "Antigravity",
// open: async (path, lineNumber, columnNumber) => {
// const { exec } = await import("node:child_process");
// exec(
// `antigravity -g "${path.replaceAll("$", "\\$")}${lineNumber ? `:${lineNumber}` : ""}${columnNumber ? `:${columnNumber}` : ""}"`,
// );
// },
// },
enhancedLogs: {
enabled: true,
},
logging: true,
consolePiping: {
enabled: true,
levels: ["log", "warn", "error", "info", "debug"],
},
}),
nitro({
vercel: {
functions: {
maxDuration: 799,
runtime: "bun1.x",
supportsResponseStreaming: true,
},
},
}),
// this is the plugin that enables path aliases
viteTsConfigPaths({
projects: ["./tsconfig.json"],
}),
tailwindcss(),
tanstackStart({
router: {},
}),
viteReact(),
],
resolve: {
dedupe: ["@platejs/core"],
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("@platejs/") || id.includes("platejs")) return "editor";
if (id.includes("@radix-ui/")) return "ui";
if (id.includes("@sentry/")) return "sentry";
},
},
},
},
ssr: {
noExternal: [/^@platejs\//, "katex", "react-tweet"],
external: ["dexie", "tanstack-dexie-db-collection", "fsevents"],
},
});
export default config;