-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
78 lines (76 loc) · 2.34 KB
/
Copy pathvite.config.ts
File metadata and controls
78 lines (76 loc) · 2.34 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
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import path from "node:path";
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
const plugins = [
react(),
tailwindcss(),
VitePWA({
registerType: "autoUpdate",
injectRegister: "auto",
manifest: {
name: "Math Tiles",
short_name: "MathTiles",
description: "Real-time computer vision math game for kids",
theme_color: "#00f5ff",
background_color: "#050510",
display: "standalone",
orientation: "landscape",
scope: "/",
start_url: "/",
icons: [
{ src: "/icon.svg", sizes: "any", type: "image/svg+xml", purpose: "any maskable" },
],
},
workbox: {
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024, // 5 MB — needed for TF.js bundle
navigateFallback: "/index.html",
navigateFallbackDenylist: [/^\/api\//, /^\/camera-test/],
runtimeCaching: [
{
// API calls — always fresh
urlPattern: /^\/api\/trpc\/.*/,
handler: "NetworkFirst",
options: { cacheName: "trpc-api-cache", networkTimeoutSeconds: 5 },
},
{
// TensorFlow.js model files — large, cache-first
urlPattern: /tfjs-model|\.bin$|model\.json/,
handler: "CacheFirst",
options: { cacheName: "tf-model-cache", expiration: { maxAgeSeconds: 30 * 24 * 60 * 60 } },
},
{
// Static assets (JS, CSS, images)
urlPattern: /\.(js|css|woff2?|png|svg|ico|webp)$/,
handler: "CacheFirst",
options: { cacheName: "static-assets-cache", expiration: { maxAgeSeconds: 7 * 24 * 60 * 60 } },
},
],
},
}),
];
export default defineConfig({
plugins,
resolve: {
alias: {
"@": path.resolve(import.meta.dirname, "client", "src"),
"@shared": path.resolve(import.meta.dirname, "shared"),
"@assets": path.resolve(import.meta.dirname, "attached_assets"),
},
},
envDir: path.resolve(import.meta.dirname),
root: path.resolve(import.meta.dirname, "client"),
publicDir: path.resolve(import.meta.dirname, "client", "public"),
build: {
outDir: path.resolve(import.meta.dirname, "dist/public"),
emptyOutDir: true,
},
server: {
host: true,
fs: {
strict: true,
deny: ["**/.*"],
},
},
});