-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
106 lines (105 loc) · 3.1 KB
/
Copy pathvite.config.js
File metadata and controls
106 lines (105 loc) · 3.1 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
import path from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { VitePWA } from "vite-plugin-pwa";
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
tailwindcss(),
VitePWA({
registerType: "autoUpdate",
includeAssets: ["favicon.png", "icon-180.png", "icon.svg"],
manifest: {
name: "Kelane",
short_name: "Kelane",
description: "Your personal recipe manager and meal planner",
theme_color: "#150404",
background_color: "#150404",
display: "standalone",
orientation: "portrait-primary",
scope: "/",
start_url: "/",
icons: [
{
src: "/icon-192.png",
sizes: "192x192",
type: "image/png",
purpose: "any",
},
{
src: "/icon-512.png",
sizes: "512x512",
type: "image/png",
purpose: "any",
},
{
src: "/icon-maskable-512.png",
sizes: "512x512",
type: "image/png",
purpose: "maskable",
},
],
screenshots: [
{
src: "/icon-512.png",
sizes: "512x512",
type: "image/png",
form_factor: "narrow",
},
],
},
workbox: {
// The web-llm bundle is very large — raise the limit so the build doesn't error.
// Large JS chunks won't be precached but will be cached on first runtime access.
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10 MiB
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff2}"],
navigateFallback: "/",
navigateFallbackDenylist: [/^\/api/, /^\/proxy/],
runtimeCaching: [
{
// Cache recipe images from the web
urlPattern: /^https:\/\/.*\.(png|jpg|jpeg|webp|gif|svg)$/i,
handler: "CacheFirst",
options: {
cacheName: "images",
expiration: { maxEntries: 200, maxAgeSeconds: 60 * 60 * 24 * 30 },
},
},
{
// Cache font files
urlPattern: /^https:\/\/fonts\.(googleapis|gstatic)\.com\//,
handler: "StaleWhileRevalidate",
options: { cacheName: "fonts" },
},
{
// OpenFoodFacts nutrition lookups — short cache
urlPattern: /^https:\/\/world\.openfoodfacts\.org\//,
handler: "StaleWhileRevalidate",
options: {
cacheName: "nutrition",
expiration: { maxEntries: 500, maxAgeSeconds: 60 * 60 * 24 * 7 },
},
},
],
},
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
// Split the massive web-llm bundle into its own chunk
"web-llm": ["@mlc-ai/web-llm"],
"vendor-react": ["react", "react-dom", "react-router"],
},
},
},
},
});