-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
99 lines (98 loc) · 3.13 KB
/
vite.config.js
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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { VitePWA } from "vite-plugin-pwa";
import { defineConfig as defineTestConfig } from "vitest/config"; // Importación de Vitest
export default defineConfig({
plugins: [
react(),
VitePWA({
registerType: "autoUpdate",
manifest: {
name: "OptiCenter Huejutla",
short_name: "Opticenter",
description: "Aplicacion web progresiva para OptiCenter Huejutla",
theme_color: "#ffffff",
display: "standalone",
icons: [
{
src: "https://res.cloudinary.com/dlrixqhln/image/upload/v1730020907/jb2g4qjct7darl5gbk9q.jpg",
sizes: "192x192",
type: "image/png",
},
{
src: "https://res.cloudinary.com/dlrixqhln/image/upload/v1730020914/nz3yhrnx3kufxres1yda.jpg",
sizes: "512x512",
type: "image/png",
},
],
screenshots: [
{
src: "/src/img/cap2.png",
sizes: "1280x720",
type: "image/png",
form_factor: "wide",
},
{
src: "/src/img/cap1.png",
sizes: "720x1280",
type: "image/png",
form_factor: "narrow",
},
],
},
workbox: {
globPatterns: ["**/*.{js,css,html,png,svg}", "offline.html"],
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
runtimeCaching: [
{
urlPattern:
/https:\/\/backopt-production.up.railway.app\/productos\/productos/,
handler: "StaleWhileRevalidate",
options: {
cacheName: "productos-cache",
expiration: {
maxEntries: 50,
maxAgeSeconds: 24 * 60 * 60,
},
},
},
{
urlPattern: ({ request }) =>
request.destination === "document" ||
request.destination === "script" ||
request.destination === "style",
handler: "CacheFirst",
options: {
cacheName: "app-shell-cache",
expiration: {
maxEntries: 10,
maxAgeSeconds: 7 * 24 * 60 * 60, // Cache por 1 semana
},
},
},
{
urlPattern: ({ request }) => request.destination === "image",
handler: "CacheFirst",
options: {
cacheName: "images-cache",
expiration: {
maxEntries: 50,
maxAgeSeconds: 30 * 24 * 60 * 60, // Cache por 1 mes
},
},
},
],
offlineGoogleAnalytics: true,
navigateFallback: "/offline.html", // Fallback cuando está offline
},
devOptions: {
enabled: true, // Habilita para desarrollo local
},
}),
],
test: {
globals: true, // Habilita funciones globales como describe, it, expect
environment: "jsdom", // Configura el entorno de prueba como jsdom
setupFiles: "./src/setupTests.ts", // Opcional: archivo de configuración para pruebas
},
});