2026-08-15 05:27:48 +03:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
2026-09-01 20:50:42 +03:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
2026-09-08 17:38:13 +03:00
|
|
|
import { fileURLToPath, URL } from 'node:url'
|
2026-08-15 05:27:48 +03:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
2026-09-01 20:50:42 +03:00
|
|
|
plugins: [
|
2026-09-12 12:07:28 +03:00
|
|
|
svelte({
|
|
|
|
|
onwarn(warning, handler) {
|
|
|
|
|
if (
|
|
|
|
|
warning.code.startsWith('a11y_') ||
|
|
|
|
|
warning.code === 'slot_element_deprecated' ||
|
|
|
|
|
warning.code === 'svelte_self_deprecated' ||
|
|
|
|
|
warning.code === 'non_reactive_update'
|
|
|
|
|
) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
handler(warning);
|
|
|
|
|
}
|
|
|
|
|
}),
|
2026-09-01 20:50:42 +03:00
|
|
|
VitePWA({
|
2026-09-17 04:45:16 +03:00
|
|
|
registerType: 'prompt',
|
|
|
|
|
injectRegister: 'auto',
|
2026-09-12 12:07:28 +03:00
|
|
|
workbox: {
|
2026-09-17 04:45:16 +03:00
|
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,wasm}'],
|
|
|
|
|
// Важно: не кэшируем API endpoint версии
|
|
|
|
|
navigateFallbackDenylist: [/^\/api\/version/],
|
|
|
|
|
runtimeCaching: [
|
|
|
|
|
{
|
|
|
|
|
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
|
|
|
|
|
handler: 'CacheFirst',
|
|
|
|
|
options: {
|
|
|
|
|
cacheName: 'google-fonts-cache',
|
|
|
|
|
expiration: {
|
|
|
|
|
maxEntries: 10,
|
|
|
|
|
maxAgeSeconds: 60 * 60 * 24 * 365 // 1 год
|
|
|
|
|
},
|
|
|
|
|
cacheableResponse: {
|
|
|
|
|
statuses: [0, 200]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
2026-09-12 12:07:28 +03:00
|
|
|
},
|
2026-09-01 20:50:42 +03:00
|
|
|
manifest: {
|
|
|
|
|
name: 'UnitPrint',
|
|
|
|
|
short_name: 'UnitPrint',
|
|
|
|
|
start_url: '/',
|
|
|
|
|
display: 'standalone',
|
|
|
|
|
background_color: '#ffffff',
|
2026-09-17 04:45:16 +03:00
|
|
|
theme_color: '#6366f1',
|
2026-09-01 20:50:42 +03:00
|
|
|
icons: [
|
|
|
|
|
{
|
|
|
|
|
src: '/icon-192x192.png',
|
|
|
|
|
sizes: '192x192',
|
|
|
|
|
type: 'image/png'
|
2026-09-17 04:45:16 +03:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
src: '/icon-512x512.png',
|
|
|
|
|
sizes: '512x512',
|
|
|
|
|
type: 'image/png'
|
2026-09-01 20:50:42 +03:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
],
|
2026-09-08 17:38:13 +03:00
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
$lib: fileURLToPath(new URL('./src/lib', import.meta.url))
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-09-05 01:27:59 +03:00
|
|
|
server: {
|
|
|
|
|
proxy: {
|
|
|
|
|
'/api': {
|
|
|
|
|
target: 'http://localhost:3000',
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, '')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-08-15 05:27:48 +03:00
|
|
|
})
|