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.
This commit is contained in:
ashwinkumaragurubaran 2026-08-06 16:52:42 +05:30
parent 7a3a93d1de
commit e78aa98677
4 changed files with 25 additions and 3 deletions

View File

@ -10,6 +10,8 @@
<meta name="apple-mobile-web-app-title" content="Krishna Sales" /> <meta name="apple-mobile-web-app-title" content="Krishna Sales" />
<link rel="apple-touch-icon" href="/apple-touch-icon-180x180.png" /> <link rel="apple-touch-icon" href="/apple-touch-icon-180x180.png" />
<title>Krishna Sales</title> <title>Krishna Sales</title>
<!--BASE_HREF-->
<script src="./config.js"></script>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View File

@ -12,10 +12,16 @@ function RootRedirect() {
return <Navigate to={getDefaultRoute(roles, isAdmin)} replace />; return <Navigate to={getDefaultRoute(roles, isAdmin)} replace />;
} }
// Mount path comes from the document <base href> the frontgen server writes at
// placement time (e.g. "/krishna-sales-mobile/"), so one built artifact serves
// any mount without a hardcoded slug. Falls back to "/" for local dev.
const routerBasename =
(document.querySelector('base')?.getAttribute('href') || '/').replace(/\/$/, '') || '/'
function App() { function App() {
return ( return (
<AuthProvider> <AuthProvider>
<BrowserRouter basename='/krishna_sales_mobile'> <BrowserRouter basename={routerBasename}>
<Routes> <Routes>
<Route path="/login" element={<LoginPage />} /> <Route path="/login" element={<LoginPage />} />
<Route element={<ConsoleLayout />}> <Route element={<ConsoleLayout />}>

View File

@ -5,7 +5,17 @@
// docs under src/docs/api. // docs under src/docs/api.
export const APP_ID = '434'; export const APP_ID = '434';
export const BASE_URL = 'https://dev.getzino.in';
// Backend URL comes from the runtime config.js the frontgen server writes at
// placement time (window.__RUNTIME_CONFIG__.VITE_ZINO_API_URL) so one built
// artifact can be promoted across environments. The dev literal is only a
// fallback for local dev / a build served without config.js.
declare global {
interface Window { __RUNTIME_CONFIG__?: Record<string, string> }
}
export const BASE_URL =
(typeof window !== 'undefined' && window.__RUNTIME_CONFIG__?.VITE_ZINO_API_URL) ||
'https://dev.getzino.in';
// --- Order Booking (src/docs/api/order_booking.md) --- // --- Order Booking (src/docs/api/order_booking.md) ---
export const ORDER_BOOKING = { export const ORDER_BOOKING = {

View File

@ -4,7 +4,11 @@ import tailwindcss from '@tailwindcss/vite'
import { VitePWA } from 'vite-plugin-pwa' import { VitePWA } from 'vite-plugin-pwa'
// https://vite.dev/config/ // https://vite.dev/config/
const base = process.env.VITE_BASE_URL ?? '/krishna_sales_mobile' // 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({ export default defineConfig({
base, base,