2026-05-03 19:51:57 -05:00
|
|
|
import { defineConfig } from 'vite';
|
|
|
|
|
import react from '@vitejs/plugin-react';
|
refactor: component splits, PWA support, CommandPalette
Component Splits:
- AdminPage.jsx: 1,906 -> 82 lines (logic moved to client/components/admin/ — 9 files)
- DataPage.jsx: 3,132 -> 60 lines (logic moved to client/components/data/ — 8 files)
- TrackerPage.jsx: 2,566 -> 2,132 lines (MonthlyStateDialog, StartingAmountsEditDialog, PaymentModal)
PWA:
- vite-plugin-pwa installed with NetworkFirst caching for API routes
- Square PWA icons (192x192, 512x512, apple-touch-icon)
- theme-color, apple meta tags, touch icon in index.html
- Build generates dist/sw.js + Workbox runtime
CommandPalette:
- Navigation commands, Add bill action, month jumps
- Grouped results with empty/filtered states
2026-05-28 20:53:22 -05:00
|
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
2026-05-03 19:51:57 -05:00
|
|
|
import path from 'path';
|
|
|
|
|
import { fileURLToPath } from 'url';
|
2026-05-14 21:00:07 -05:00
|
|
|
import { createRequire } from 'module';
|
2026-05-03 19:51:57 -05:00
|
|
|
|
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
2026-05-14 21:00:07 -05:00
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
|
const pkg = require('./package.json');
|
2026-06-06 20:44:54 -05:00
|
|
|
const apiPort = process.env.API_PORT || process.env.PORT || 3000;
|
2026-05-03 19:51:57 -05:00
|
|
|
|
|
|
|
|
export default defineConfig({
|
refactor: component splits, PWA support, CommandPalette
Component Splits:
- AdminPage.jsx: 1,906 -> 82 lines (logic moved to client/components/admin/ — 9 files)
- DataPage.jsx: 3,132 -> 60 lines (logic moved to client/components/data/ — 8 files)
- TrackerPage.jsx: 2,566 -> 2,132 lines (MonthlyStateDialog, StartingAmountsEditDialog, PaymentModal)
PWA:
- vite-plugin-pwa installed with NetworkFirst caching for API routes
- Square PWA icons (192x192, 512x512, apple-touch-icon)
- theme-color, apple meta tags, touch icon in index.html
- Build generates dist/sw.js + Workbox runtime
CommandPalette:
- Navigation commands, Add bill action, month jumps
- Grouped results with empty/filtered states
2026-05-28 20:53:22 -05:00
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
VitePWA({
|
|
|
|
|
registerType: 'autoUpdate',
|
|
|
|
|
includeAssets: ['img/logo.png', 'img/pwa-192.png', 'img/pwa-512.png'],
|
|
|
|
|
manifest: {
|
|
|
|
|
name: 'BillTracker',
|
|
|
|
|
short_name: 'BillTracker',
|
|
|
|
|
description: 'Personal bill planning and tracking',
|
|
|
|
|
theme_color: '#18181b',
|
|
|
|
|
background_color: '#18181b',
|
|
|
|
|
display: 'standalone',
|
|
|
|
|
start_url: '/',
|
|
|
|
|
icons: [
|
|
|
|
|
{ src: '/img/pwa-192.png', sizes: '192x192', type: 'image/png' },
|
|
|
|
|
{ src: '/img/pwa-512.png', sizes: '512x512', type: 'image/png', purpose: 'any maskable' },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
workbox: {
|
|
|
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
|
|
|
|
runtimeCaching: [
|
|
|
|
|
{
|
|
|
|
|
urlPattern: /^\/api\/(tracker|bills|calendar|summary|analytics|snowball|categories)/,
|
|
|
|
|
handler: 'NetworkFirst',
|
|
|
|
|
options: {
|
|
|
|
|
cacheName: 'api-cache',
|
|
|
|
|
networkTimeoutSeconds: 5,
|
|
|
|
|
expiration: { maxEntries: 30, maxAgeSeconds: 300 },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
],
|
2026-05-03 22:33:21 -05:00
|
|
|
publicDir: 'client/public',
|
2026-05-14 21:00:07 -05:00
|
|
|
define: {
|
|
|
|
|
// Injected at build time — frontend reads this instead of maintaining a
|
|
|
|
|
// duplicate version string in client/lib/version.js
|
|
|
|
|
__APP_VERSION__: JSON.stringify(pkg.version),
|
|
|
|
|
},
|
2026-05-03 19:51:57 -05:00
|
|
|
resolve: {
|
|
|
|
|
alias: { '@': path.resolve(__dirname, './client') },
|
|
|
|
|
},
|
|
|
|
|
server: {
|
|
|
|
|
port: 5173,
|
|
|
|
|
proxy: {
|
2026-06-06 20:44:54 -05:00
|
|
|
'/api': { target: `http://localhost:${apiPort}`, changeOrigin: true },
|
2026-05-03 19:51:57 -05:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
outDir: 'dist',
|
|
|
|
|
emptyOutDir: true,
|
2026-07-02 20:47:50 -05:00
|
|
|
rollupOptions: {
|
|
|
|
|
output: {
|
|
|
|
|
// QA-B0-01: split the shared vendor code out of the ~659 kB index chunk
|
|
|
|
|
// so large libs load/cache independently and the main bundle shrinks.
|
|
|
|
|
manualChunks: {
|
|
|
|
|
'vendor-react': ['react', 'react-dom', 'react-router-dom'],
|
|
|
|
|
'vendor-radix': [
|
|
|
|
|
'@radix-ui/react-dialog', '@radix-ui/react-select', '@radix-ui/react-dropdown-menu',
|
|
|
|
|
'@radix-ui/react-tabs', '@radix-ui/react-tooltip', '@radix-ui/react-alert-dialog',
|
|
|
|
|
],
|
|
|
|
|
'vendor-motion': ['framer-motion'],
|
|
|
|
|
'vendor-query': ['@tanstack/react-query', '@tanstack/react-virtual'],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-05-03 19:51:57 -05:00
|
|
|
},
|
2026-06-12 01:32:28 -05:00
|
|
|
// Vitest — client-side unit tests (pure logic in client/lib).
|
|
|
|
|
// Server tests stay on node:test (`npm run test`); client tests run with
|
|
|
|
|
// `npm run test:client`; `npm run test:all` runs both.
|
|
|
|
|
test: {
|
2026-06-12 02:08:42 -05:00
|
|
|
environment: 'node', // hook/component tests opt into jsdom via @vitest-environment
|
|
|
|
|
include: ['client/**/*.test.{js,jsx}'],
|
2026-06-12 01:32:28 -05:00
|
|
|
},
|
2026-05-03 19:51:57 -05:00
|
|
|
});
|