-
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.33 KB
/
vite.config.ts
File metadata and controls
78 lines (76 loc) · 2.33 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 vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import { VitePWA } from 'vite-plugin-pwa'
import tsconfigPaths from 'vite-tsconfig-paths'
// https://vitejs.dev/config/
export default defineConfig(({ command }) => ({
base: '/radio',
build: {
chunkSizeWarningLimit: 500,
rollupOptions: {
output: {
manualChunks: {
utils: ['@vueuse/core'],
vue: ['vue'],
},
},
},
},
esbuild: {
drop: ['console', 'debugger'], // Убираем console и debugger
},
plugins: [
vue(),
tsconfigPaths(),
// PWA только для production
command === 'build' && VitePWA({
registerType: 'autoUpdate', // Автоматическое обновление
workbox: {
// Кеш автоматически инвалидируется при изменении контента
cleanupOutdatedCaches: true,
globPatterns: [
'**/*.{js,css,html,png,svg,json,woff2,webp}',
],
runtimeCaching: [
// Главная страница - NetworkFirst с увеличенным TTL
{
handler: 'NetworkFirst',
options: {
cacheName: 'pages',
expiration: {
maxAgeSeconds: 7 * 24 * 60 * 60, // 1 неделя
maxEntries: 10,
},
networkTimeoutSeconds: 3,
},
urlPattern: ({ url }) => url.pathname === '/' || url.pathname === '/radio',
},
// JS/CSS файлы - CacheFirst с долгим TTL
{
handler: 'CacheFirst',
options: {
cacheName: 'static-resources',
expiration: {
maxAgeSeconds: 30 * 24 * 60 * 60, // 1 месяц
maxEntries: 50,
},
},
urlPattern: /\.(?:js|css)$/,
},
// Изображения - CacheFirst с увеличенным TTL
{
handler: 'CacheFirst',
options: {
cacheName: 'images',
expiration: {
maxAgeSeconds: 14 * 24 * 60 * 60, // 2 недели
maxEntries: 100,
},
},
urlPattern: /\.(?:png|svg|webp)$/,
},
],
},
}),
].filter(Boolean),
}))