87 lines
1.9 KiB
TypeScript
87 lines
1.9 KiB
TypeScript
import { fileURLToPath } from 'node:url'
|
|
import path from 'node:path'
|
|
|
|
import react from '@vitejs/plugin-react-swc'
|
|
import { defineConfig } from 'vite'
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
|
const pwaPlugin = VitePWA({
|
|
registerType: 'autoUpdate',
|
|
includeAssets: ['pwa-icon.svg', 'pwa-192x192.png', 'pwa-512x512.png'],
|
|
manifest: {
|
|
name: 'Kitchen CRM',
|
|
short_name: 'KitchenCRM',
|
|
display: 'standalone',
|
|
start_url: '/',
|
|
lang: 'en',
|
|
description: 'Multi-tenant CRM dashboard for organizations, contacts, deals, and analytics.',
|
|
background_color: '#020617',
|
|
theme_color: '#0f172a',
|
|
icons: [
|
|
{
|
|
src: '/pwa-icon.svg',
|
|
sizes: 'any',
|
|
type: 'image/svg+xml',
|
|
},
|
|
{
|
|
src: '/pwa-192x192.png',
|
|
sizes: '192x192',
|
|
type: 'image/png',
|
|
},
|
|
{
|
|
src: '/pwa-512x512.png',
|
|
sizes: '512x512',
|
|
type: 'image/png',
|
|
purpose: 'any maskable',
|
|
},
|
|
],
|
|
},
|
|
devOptions: {
|
|
enabled: true,
|
|
suppressWarnings: true,
|
|
},
|
|
workbox: {
|
|
globPatterns: ['**/*.{js,css,html,png,svg,ico,webmanifest,json}'],
|
|
runtimeCaching: [
|
|
{
|
|
urlPattern: ({ url }) => url.pathname.startsWith('/api'),
|
|
handler: 'NetworkFirst',
|
|
options: {
|
|
cacheName: 'api-cache',
|
|
networkTimeoutSeconds: 5,
|
|
expiration: {
|
|
maxEntries: 50,
|
|
maxAgeSeconds: 60 * 15,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
urlPattern: ({ request }) => request.destination === 'document',
|
|
handler: 'NetworkFirst',
|
|
},
|
|
],
|
|
},
|
|
})
|
|
|
|
export default defineConfig({
|
|
plugins: [react(), pwaPlugin],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src'),
|
|
},
|
|
},
|
|
envPrefix: 'VITE_',
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 5173,
|
|
},
|
|
preview: {
|
|
port: 4173,
|
|
},
|
|
build: {
|
|
target: 'es2022',
|
|
},
|
|
})
|