Files
web-app/vite.config.js

92 lines
2.5 KiB
JavaScript
Raw Normal View History

2026-08-15 05:27:48 +03:00
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
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({
plugins: [
svelte({
onwarn(warning, handler) {
if (
2026-09-18 20:24:45 +03:00
warning.code.startsWith('a11y_') ||
warning.code === 'slot_element_deprecated' ||
warning.code === 'svelte_self_deprecated' ||
warning.code === 'non_reactive_update'
) {
return;
}
handler(warning);
}
}),
VitePWA({
2026-09-17 04:45:16 +03:00
registerType: 'prompt',
injectRegister: 'auto',
workbox: {
2026-09-18 20:24:45 +03:00
clientsClaim: true,
// Добавили mjs, чтобы pdf.worker.min.mjs попадал в precache Нужно для PDFJS
globPatterns: ['**/*.{js,mjs,css,html,ico,png,svg,wasm}'],
2026-09-17 04:45:16 +03:00
navigateFallbackDenylist: [/^\/api\/version/],
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-cache',
expiration: {
maxEntries: 10,
2026-09-18 20:24:45 +03:00
maxAgeSeconds: 60 * 60 * 24 * 365
2026-09-17 04:45:16 +03:00
},
cacheableResponse: {
statuses: [0, 200]
}
}
2026-09-18 20:24:45 +03:00
},
// Fallback кэширование для worker-файлов, если они не попали в precache
{
urlPattern: /\/assets\/.*\.(mjs|js)$/,
handler: 'CacheFirst',
options: {
cacheName: 'worker-cache',
expiration: { maxEntries: 20, maxAgeSeconds: 60 * 60 * 24 * 30 }
}
2026-09-17 04:45:16 +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',
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-08 17:38:13 +03:00
resolve: {
alias: {
$lib: fileURLToPath(new URL('./src/lib', import.meta.url))
}
},
server: {
proxy: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
2026-09-18 03:22:00 +03:00
rewrite: (path) => path.replace(/^\/api/, '')
}
}
}
2026-08-15 05:27:48 +03:00
})