-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
119 lines (115 loc) · 3.62 KB
/
Copy pathvite.config.ts
File metadata and controls
119 lines (115 loc) · 3.62 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import path from 'path'
import { execSync } from 'child_process'
import { cloudflare } from "@cloudflare/vite-plugin";
import { VitePWA } from "vite-plugin-pwa";
const gitHash = execSync('git rev-parse --short HEAD').toString().trim();
// https://vite.dev/config/
export default defineConfig(({ mode }) => {
const isCapacitorBuild = mode.startsWith('capacitor');
return {
define: {
__GIT_HASH__: JSON.stringify(gitHash),
},
plugins: [
react(),
tailwindcss(),
!isCapacitorBuild && cloudflare(),
!isCapacitorBuild && VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.png', 'apple-touch-icon.png'],
devOptions: {
enabled: true
},
workbox: {
cleanupOutdatedCaches: true,
clientsClaim: true,
skipWaiting: true,
globPatterns: ['**/*.{js,css,woff,woff2,ttf,webmanifest}'],
maximumFileSizeToCacheInBytes: 5000000,
// Keep navigations network-first. A cached SPA shell is what makes
// installed PWAs keep loading stale chunk hashes after deployments.
navigateFallback: undefined,
// Do not let the SPA "offline shell" hijack top-level navigations to the API
// (e.g. Google OAuth start URL /api/auth/google -> must hit the network / worker).
navigateFallbackDenylist: [/^\/api\//, /^\/ws\//, /^\/v1\//, /^\/health$/],
},
manifest: {
id: '/',
name: 'construct.computer',
short_name: 'Construct',
description: 'AI Agent Platform - Your AI agents run autonomously 24/7',
theme_color: '#000000',
background_color: '#000000',
display: 'standalone',
icons: [
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png'
}
]
}
})
,
].filter(Boolean),
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
port: 5173,
hmr: {
port: 5173,
},
allowedHosts: ['host.docker.internal'],
// Proxy API and WebSocket requests to wrangler dev (Cloudflare Worker)
proxy: {
'/api': {
target: 'http://localhost:8787',
changeOrigin: true,
},
'/ws': {
target: 'ws://localhost:8787',
ws: true,
},
'/health': {
target: 'http://localhost:8787',
changeOrigin: true,
},
},
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (!id.includes('node_modules')) return undefined;
if (id.includes('/react/') || id.includes('/react-dom/') || id.includes('/scheduler/')) return 'react-vendor';
if (id.includes('/monaco-editor/') || id.includes('/@monaco-editor/')) return 'editor-vendor';
if (id.includes('/@xterm/')) return 'terminal-vendor';
if (id.includes('/xlsx/')) return 'spreadsheet-vendor';
if (id.includes('/mammoth/') || id.includes('/@jvmr/pptx-to-html/')) return 'document-vendor';
if (
id.includes('/react-markdown/')
|| id.includes('/remark-')
|| id.includes('/rehype-')
|| id.includes('/unified/')
|| id.includes('/katex/')
|| id.includes('/highlight.js/')
) return 'markdown-vendor';
if (id.includes('/lucide-react/')) return 'icons-vendor';
return undefined;
},
},
},
},
};
})