forked from edideaur/monochrome
-
-
Notifications
You must be signed in to change notification settings - Fork 421
Expand file tree
/
Copy pathvite.config.ts
More file actions
165 lines (159 loc) · 6.09 KB
/
Copy pathvite.config.ts
File metadata and controls
165 lines (159 loc) · 6.09 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import path from 'path';
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
import authGatePlugin from './vite-plugin-auth-gate.js';
import blobAssetPlugin from './vite-plugin-blob.js';
import svgUse from './vite-plugin-svg-use.js';
import uploadPlugin from './vite-plugin-upload.js';
import { playwright } from '@vitest/browser-playwright';
import { execSync } from 'child_process';
function proxyAudioPlugin() {
return {
name: 'proxy-audio-dev',
configureServer(server) {
// No longer needed: local proxy-audio middleware replaced by remote proxy
},
};
}
function getGitCommitHash() {
try {
return execSync('git rev-parse --short HEAD').toString().trim();
} catch {
return 'unknown';
}
}
const decrypterVersion = '2026-08-06-crossfade-v10';
export default defineConfig(({ mode }) => {
const commitHash = getGitCommitHash();
const isDev = mode === 'development';
return {
test: {
// https://vitest.dev/guide/browser/
browser: {
enabled: true,
provider: playwright(),
headless: !!process.env.HEADLESS,
instances: [{ browser: 'chromium' }],
},
},
base: './',
define: {
__COMMIT_HASH__: JSON.stringify(commitHash),
__VITEST__: !!process.env.VITEST,
},
worker: {
format: 'es',
},
resolve: {
alias: {
'!lucide': '/node_modules/lucide-static/icons',
'!simpleicons': '/node_modules/simple-icons/icons',
'!': '/node_modules',
events: '/node_modules/events/events.js',
pocketbase: '/node_modules/pocketbase/dist/pocketbase.es.js',
stream: path.resolve(__dirname, 'stream-stub.js'), // Stub for stream module
},
},
optimizeDeps: {
exclude: ['pocketbase', '@ffmpeg/ffmpeg', '@ffmpeg/util'],
},
server: {
fs: {
allow: ['.', 'node_modules'],
// host: true,
// allowedHosts: ['<your_tailscale_hostname>'], // e.g. pi5.tailf5f622.ts.net
},
},
// preview: {
// host: true,
// allowedHosts: ['<your_tailscale_hostname>'], // e.g. pi5.tailf5f622.ts.net
// },
build: {
outDir: 'dist',
emptyOutDir: true,
sourcemap: false,
minify: 'esbuild',
reportCompressedSize: false,
rollupOptions: {
treeshake: true,
},
},
plugins: [
proxyAudioPlugin(),
authGatePlugin(),
uploadPlugin(),
blobAssetPlugin(),
svgUse(),
VitePWA({
registerType: 'prompt',
devOptions: {
enabled: true,
type: 'classic',
disableRuntimeConfig: true,
suppressWarnings: true,
},
workbox: {
importScripts: [`sw-decrypter.js?v=${decrypterVersion}`],
skipWaiting: true,
clientsClaim: true,
globPatterns: ['index.html', 'manifest.json'],
cleanupOutdatedCaches: true,
maximumFileSizeToCacheInBytes: 3 * 1024 * 1024, // 3 MiB limit
// Define runtime caching strategies
runtimeCaching: [
{
urlPattern: ({ request }) =>
request.destination === 'script' || request.destination === 'worker',
handler: isDev ? 'NetworkFirst' : 'CacheFirst',
options: {
cacheName: 'scripts',
expiration: {
maxEntries: 200,
maxAgeSeconds: 60 * 24 * 60 * 60,
},
},
},
{
urlPattern: ({ request }) =>
request.destination === 'style' || request.destination === 'font',
handler: 'CacheFirst',
options: {
cacheName: 'static-resources',
expiration: {
maxEntries: 60,
maxAgeSeconds: 60 * 24 * 60 * 60,
},
},
},
{
urlPattern: ({ request }) => request.destination === 'image',
handler: 'CacheFirst',
options: {
cacheName: 'images',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 24 * 60 * 60, // 60 Days
},
},
},
{
urlPattern: ({ request }) =>
request.destination === 'audio' || request.destination === 'video',
handler: 'CacheFirst',
options: {
cacheName: 'media',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 24 * 60 * 60, // 60 Days
},
rangeRequests: true, // Support scrubbing
},
},
],
},
includeAssets: ['discord.html'],
manifest: false, // Use existing public/manifest.json
}),
],
};
});