-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
106 lines (103 loc) · 3.33 KB
/
Copy pathvite.config.ts
File metadata and controls
106 lines (103 loc) · 3.33 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 { defineConfig } from 'vite'
import type { Plugin } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { fileURLToPath, URL } from 'node:url'
import { VitePWA } from 'vite-plugin-pwa'
// WebContainers require every app response to be cross-origin isolated.
function coepPlugin(): Plugin {
return {
name: 'coep-headers',
configureServer(server) {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Embedder-Policy', 'credentialless');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
next();
});
},
// Also handle build preview (vite preview)
configurePreviewServer(server) {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Embedder-Policy', 'credentialless');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
next();
});
}
};
}
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
plugins: [
react(),
tailwindcss({ optimize: false }),
coepPlugin(),
VitePWA({
// Keep the old worker active until the user accepts the update. Activating
// a new precache while an old page is running can break lazy chunk loads.
registerType: 'prompt',
includeAssets: [
'icon-bg-svg.svg',
'icon-nobg-svg.svg',
],
workbox: {
// Succinix host 运行时资产(host.js / lifo-core.js / pyodide)是注入 WebContainer
// 的懒加载基础设施,不进 SW 预缓存(单文件可达 9.6MB,超出 workbox 默认上限)。
globIgnores: ['**/succinix/**', '**/pyodide/**'],
},
manifest: {
name: 'Sunam',
short_name: 'Sunam',
description: 'Sunam Agent Coding Assistant',
theme_color: '#ffffff',
background_color: '#ffffff',
display: 'standalone',
icons: [
{
src: 'sunam-appicon-192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: 'sunam-appicon-512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable'
}
]
}
})
],
server: {
port: 7891,
strictPort: true,
},
build: {
target: 'es2023',
minify: 'terser',
terserOptions: {
compress: { passes: 4 },
},
rollupOptions: {
output: {
manualChunks(id) {
// @succinix/engine is an external plugin consumed as a runtime
// dependency. Keep its browser-side implementation in a dedicated
// chunk so application JS budgets can account for it separately.
// The file: dependency is a symlink; Vite may expose either the
// node_modules path or the real package path.
if (id.includes('/@succinix/engine/') || id.includes('/packages/engine/')) return 'succinix-engine';
},
},
},
// Lightning CSS currently collapses the source declaration pair to a WebKit-only
// declaration. Esbuild preserves both the standard property used by
// Chromium/Firefox and the Safari-compatible prefixed declaration.
cssMinify: 'esbuild',
cssTarget: ['chrome100', 'firefox103', 'safari15.4'],
},
})