-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
75 lines (74 loc) · 2.53 KB
/
Copy pathvite.config.ts
File metadata and controls
75 lines (74 loc) · 2.53 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
import { defineConfig } from "vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import viteReact from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import tsConfigPaths from "vite-tsconfig-paths";
import { VitePWA } from "vite-plugin-pwa";
export default defineConfig({
plugins: [
tanstackStart({
server: { entry: "server" },
}),
viteReact(),
tailwindcss(),
tsConfigPaths(),
VitePWA({
registerType: "autoUpdate",
injectRegister: null,
filename: "sw.js",
devOptions: { enabled: false },
// Keep the hand-authored /public/manifest.webmanifest as the source of truth.
manifest: false,
workbox: {
navigateFallback: "/",
navigateFallbackDenylist: [/^\/api\//, /^\/~oauth\//, /^\/_/],
globPatterns: ["**/*.{js,css,html,ico,png,svg,webmanifest}"],
cleanupOutdatedCaches: true,
skipWaiting: true,
clientsClaim: true,
runtimeCaching: [
{
urlPattern: ({ request }) => request.mode === "navigate",
handler: "NetworkFirst",
options: {
cacheName: "aura-pages",
networkTimeoutSeconds: 3,
},
},
{
urlPattern: ({ url, request }) =>
url.origin === self.location.origin &&
["style", "script", "worker"].includes(request.destination),
handler: "NetworkFirst",
options: {
cacheName: "aura-code",
networkTimeoutSeconds: 3,
expiration: { maxEntries: 80, maxAgeSeconds: 60 * 60 * 24 },
},
},
{
urlPattern: ({ url, request }) =>
url.origin === self.location.origin &&
["font", "image"].includes(request.destination),
handler: "CacheFirst",
options: {
cacheName: "aura-media",
expiration: { maxEntries: 160, maxAgeSeconds: 60 * 60 * 24 * 30 },
},
},
{
urlPattern: ({ url }) =>
url.origin === "https://fonts.googleapis.com" ||
url.origin === "https://fonts.gstatic.com",
handler: "CacheFirst",
options: {
cacheName: "aura-fonts",
expiration: { maxEntries: 30, maxAgeSeconds: 60 * 60 * 24 * 365 },
},
},
],
},
}),
],
],
});