-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
98 lines (97 loc) · 2.88 KB
/
vite.config.ts
File metadata and controls
98 lines (97 loc) · 2.88 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { VitePWA } from 'vite-plugin-pwa'
import path from 'path'
import pkg from './package.json' with { type: 'json' }
export default defineConfig({
define: {
__APP_VERSION__: JSON.stringify(process.env.BUILD_VERSION || pkg.version),
__EE__: JSON.stringify(process.env.BUILD_EDITION === 'cloud'),
},
plugins: [
react(),
tailwindcss(),
VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.svg', 'pwa-192x192.png', 'pwa-512x512.png'],
manifest: {
name: 'OpenBin',
short_name: 'OpenBin',
description: 'Inventory with intelligence. Organize physical storage with QR codes and photo recognition.',
theme_color: '#000000',
background_color: '#000000',
display: 'standalone',
orientation: 'portrait',
icons: [
{
src: 'pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
],
},
workbox: {
globPatterns: ['**/*.{js,css,ico,png,svg}'],
cleanupOutdatedCaches: true,
// Disable the default precache-based navigateFallback.
// iOS aggressively evicts Cache Storage for PWAs after idle periods;
// if the precached index.html is gone the SW serves a blank page.
// Use NetworkFirst via runtimeCaching instead — fetches from the server
// first, falling back to cache only when offline.
navigateFallback: undefined,
runtimeCaching: [
{
urlPattern: ({ request }: { request: Request }) =>
request.mode === 'navigate',
handler: 'NetworkFirst',
options: {
cacheName: 'pages',
networkTimeoutSeconds: 3,
},
},
],
},
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
server: {
proxy: {
'/api': {
target: 'http://localhost:1453',
changeOrigin: true,
},
},
},
build: {
rollupOptions: {
output: {
experimentalMinChunkSize: 5000,
manualChunks(id) {
if (id.includes('node_modules/react-dom') || id.includes('node_modules/react/') || id.includes('node_modules/react-router')) {
return 'vendor-react';
}
if (id.includes('node_modules/html5-qrcode')) {
return 'vendor-scanner';
}
if (id.includes('node_modules/qrcode')) {
return 'vendor-qrcode';
}
if (id.includes('node_modules/lucide-react')) {
return 'vendor-icons';
}
},
},
},
},
})