-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathvite.config.ts
More file actions
74 lines (70 loc) · 2.84 KB
/
Copy pathvite.config.ts
File metadata and controls
74 lines (70 loc) · 2.84 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { VitePWA } from 'vite-plugin-pwa'
import path from 'path'
import os from 'os'
import { readFileSync } from 'fs'
import { execSync } from 'child_process'
// Use temp dir for cache to avoid file-locking issues
const cacheDir = path.join(os.tmpdir(), 'vite-easyschematic')
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'))
let gitHash = 'unknown'
try {
gitHash = execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim()
} catch { /* not a git repo or git not available */ }
export default defineConfig({
// Resolve TypeScript sources before .js so stale emitted .js shadows can't silently win.
resolve: {
extensions: ['.mjs', '.mts', '.ts', '.tsx', '.js', '.jsx', '.json'],
},
plugins: [
react(),
VitePWA({
// 'prompt' lets src/sw-register.ts decide what to do when a new SW
// arrives — show a pill when the user's active, silent-reload when
// they're idle. 'autoUpdate' would swallow onNeedRefresh and force a
// silent reload on every update, even mid-interaction.
registerType: 'prompt',
// We call registerSW() manually from src/main.tsx; don't let the plugin
// auto-inject a second registration script.
injectRegister: false,
workbox: {
// No skipWaiting/clientsClaim — those would auto-activate the new SW
// and immediately reload via vite-plugin-pwa's controlling listener,
// which races our pill out of existence. The pill (src/sw-register.ts
// → updateSW(true)) is now what skips waiting and reloads, on the
// user's terms or after they go idle.
maximumFileSizeToCacheInBytes: 4 * 1024 * 1024,
globPatterns: ['**/*.{js,css,html,svg,png,ttf,json}'],
globIgnores: [
'**/deviceLibrary.fallback.json',
'**/og-image.png',
'**/github-social.png',
'**/landing-screenshot.png',
'**/email-logo.png',
],
},
manifest: {
name: 'EasySchematic — AV Signal Flow Diagram Tool',
short_name: 'EasySchematic',
description: 'Design audio/video signal flow diagrams for broadcast, live production, and AV integration.',
theme_color: '#0f172a',
background_color: '#0f172a',
display: 'standalone',
scope: '/',
start_url: '/',
icons: [
{ src: 'pwa-192x192.png', sizes: '192x192', type: 'image/png' },
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png' },
{ src: 'pwa-512x512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
{ src: 'favicon.svg', sizes: 'any', type: 'image/svg+xml' },
],
},
}),
],
cacheDir,
define: {
__APP_VERSION__: JSON.stringify(pkg.version),
__BUILD_HASH__: JSON.stringify(gitHash),
},
})