-
Notifications
You must be signed in to change notification settings - Fork 163
Expand file tree
/
Copy pathvite.config.ts
More file actions
117 lines (115 loc) · 4.12 KB
/
Copy pathvite.config.ts
File metadata and controls
117 lines (115 loc) · 4.12 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { visualizer } from "rollup-plugin-visualizer";
import { VitePWA } from "vite-plugin-pwa";
const analyze = process.env.ANALYZE === "1";
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
tailwindcss(),
analyze &&
visualizer({
filename: "dist/stats.html",
gzipSize: true,
brotliSize: true,
template: "treemap",
open: false,
}),
VitePWA({
registerType: "prompt",
includeAssets: ["favicon-32x32.png", "apple-touch-icon.png", "offline.html"],
manifest: {
name: "Tikka",
short_name: "Tikka",
description: "Decentralized Raffles on Stellar",
theme_color: "#000000",
background_color: "#000000",
display: "standalone",
icons: [
{
src: "icon-192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "icon-512.png",
sizes: "512x512",
type: "image/png",
},
{
src: "icon-maskable-192.png",
sizes: "192x192",
type: "image/png",
purpose: "maskable",
},
{
src: "icon-maskable-512.png",
sizes: "512x512",
type: "image/png",
purpose: "maskable",
},
],
},
workbox: {
globPatterns: ["**/*.{js,css,html,ico,png,svg}"],
navigateFallback: "/offline.html",
runtimeCaching: [
{
// Navigation requests (HTML documents) — NetworkFirst
urlPattern: ({ request }) => request.mode === 'navigate',
handler: "NetworkFirst",
options: {
cacheName: "pages-cache",
expiration: {
maxEntries: 50,
maxAgeSeconds: 24 * 60 * 60,
},
},
},
{
// API calls — NetworkFirst
urlPattern: ({ url }) => url.pathname.startsWith('/api/'),
handler: "NetworkFirst",
options: {
cacheName: "api-cache",
expiration: {
maxEntries: 100,
maxAgeSeconds: 5 * 60,
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
{
// Raffles data — NetworkFirst
urlPattern: ({ url }) => url.pathname.includes('/raffles'),
handler: "NetworkFirst",
options: {
cacheName: "raffles-cache",
expiration: {
maxEntries: 50,
maxAgeSeconds: 5 * 60,
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
}),
].filter(Boolean),
define: {
global: "globalThis",
},
optimizeDeps: {
esbuildOptions: {
define: {
global: "globalThis",
},
},
},
});