-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
125 lines (123 loc) · 3.47 KB
/
vite.config.ts
File metadata and controls
125 lines (123 loc) · 3.47 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
import path from "path";
import { fileURLToPath } from "url";
import { createRequire } from "module";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { VitePWA } from "vite-plugin-pwa";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const require = createRequire(import.meta.url);
const pkg = require("./package.json");
export default defineConfig(({ mode }) => ({
plugins: [
react(),
tailwindcss(),
{
name: "inject-version",
transformIndexHtml(html) {
return html.replace(/%APP_VERSION%/g, pkg.version);
},
},
VitePWA({
registerType: "autoUpdate",
includeAssets: ["favicon.ico", "logo.svg"],
manifest: {
name: "Delta View",
short_name: "DeltaView",
description: "Dev Toolkit - Delta Editor with real-time transformations",
theme_color: "#000000",
background_color: "#000000",
display: "standalone",
icons: [
{
src: "logo.svg",
sizes: "any",
type: "image/svg+xml",
},
],
},
workbox: {
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2}"],
maximumFileSizeToCacheInBytes: 8 * 1024 * 1024, // 8 MB (largest file is 7.02 MB)
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: "CacheFirst",
options: {
cacheName: "google-fonts-cache",
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // 1 year
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
{
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
handler: "CacheFirst",
options: {
cacheName: "gstatic-fonts-cache",
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // 1 year
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
}),
],
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
},
root: ".",
publicDir: "public",
resolve: {
alias: { "@": path.resolve(__dirname, "src") },
},
optimizeDeps: {
include: ["react", "react-dom", "react-dom/client"],
},
server: {
port: 5173,
proxy: {
"/api": {
target: "http://localhost:3001",
changeOrigin: true,
},
},
},
build: {
outDir: "dist",
emptyOutDir: true,
sourcemap: mode !== "production",
rollupOptions: {
output: {
manualChunks: {
"react-vendor": ["react", "react-dom", "react-router-dom"],
monaco: ["@monaco-editor/react"],
reactflow: ["reactflow"],
"radix-ui": [
"@radix-ui/react-dialog",
"@radix-ui/react-dropdown-menu",
"@radix-ui/react-label",
"@radix-ui/react-scroll-area",
"@radix-ui/react-select",
"@radix-ui/react-separator",
"@radix-ui/react-slot",
"@radix-ui/react-tabs",
"@radix-ui/react-toast",
"@radix-ui/react-tooltip",
],
"syntax-highlighter": ["react-syntax-highlighter"],
"tanstack-table": ["@tanstack/react-table"],
},
},
},
},
}));