krishnasales_mobile/vite.config.ts
ashwinkumaragurubaran e78aa98677 build: make artifact placement-portable for frontend releases
- vite base './' (relative refs; PWA manifest/scope/fallback follow via concat)
- index.html carries <!--BASE_HREF--> placeholder + ./config.js ref
- BASE_URL reads window.__RUNTIME_CONFIG__.VITE_ZINO_API_URL (placement-written)
- router basename derived from <base href>, not hardcoded slug

Slug renamed krishna_sales_mobile -> krishna-sales-mobile (frontgen slug
pattern forbids underscores). Same treatment as the desktop app.
2026-08-06 16:52:42 +05:30

56 lines
1.7 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { VitePWA } from 'vite-plugin-pwa'
// https://vite.dev/config/
// Relative base so the built artifact is mount-path agnostic; the frontgen
// server writes the real <base href> into index.html at placement time.
// PWA manifest start_url/scope + workbox fallback concatenate this, so they
// stay relative too and resolve under whatever mount serves the app.
const base = './'
export default defineConfig({
base,
plugins: [
react(),
tailwindcss(),
VitePWA({
registerType: 'autoUpdate',
pwaAssets: { image: 'public/logo.png' },
manifest: {
name: 'Krishna Sales',
short_name: 'Krishna',
description: 'Field Sales console',
theme_color: '#0B1B3B',
background_color: '#0B1B3B',
display: 'standalone',
orientation: 'portrait',
start_url: base + 'orders',
scope: base,
},
workbox: {
navigateFallback: base + 'index.html',
navigateFallbackDenylist: [/^\/usr\//, /^\/app\//],
globPatterns: ['**/*.{js,css,html,svg,png,ico,woff2}'],
},
devOptions: { enabled: false },
}),
],
build: {
chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes('node_modules')) {
if (id.includes('react') || id.includes('react-dom') || id.includes('react-router-dom')) return 'vendor-react';
if (id.includes('jspdf')) return 'vendor-pdf';
if (id.includes('recharts') || id.includes('lucide-react')) return 'vendor-ui';
return 'vendor';
}
},
},
},
},
})