Match the upstream LNbits extension rebrand (Castle Accounting → Libra).
Renames the standalone PWA build artifacts and all references:
- castle.html → libra.html
- vite.castle.config.ts → vite.libra.config.ts (PWA name "Libra —
Team Accounting", short_name "Libra", manifest id libra-accounting)
- npm scripts: build:castle/dev:castle/preview:castle → build:libra
etc; dev:all and build:demo chains updated; dist-castle → dist-libra
- Hub tile: Lucide icon Castle → Scale (the scales/balance metaphor),
label "Castle" → "Libra", env var VITE_HUB_CASTLE_URL → VITE_HUB_LIBRA_URL
- ExpensesAPI: /castle/api/v1/* → /libra/api/v1/* (matches the renamed
LNbits extension's URL prefix)
- Feature flags VITE_CASTLE_INCOME_ENABLED/VITE_CASTLE_BUDGETS_ENABLED →
VITE_LIBRA_*
- i18n: top-level "castle" namespace → "libra" across en/es/fr; all
t('castle.*') usages updated
- localStorage key castle-expense-drafts → libra-expense-drafts
- nginx.conf.example: /castle/ routes + castle.<domain> redirect → libra
- Comments and identifiers: castleOwesUser → libraOwesUser, castle.api
references in docs
Source dir src/accounting-app/ stays as-is (already feature-named, not
brand-named).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
136 lines
4.4 KiB
TypeScript
136 lines
4.4 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import { defineConfig, type Plugin } from 'vite'
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer'
|
|
import { visualizer } from 'rollup-plugin-visualizer'
|
|
|
|
/**
|
|
* Plugin to rewrite dev server requests to libra.html
|
|
* (SPA fallback for the standalone Libra accounting app entry point)
|
|
*/
|
|
function libraHtmlPlugin(): Plugin {
|
|
return {
|
|
name: 'libra-html-rewrite',
|
|
configureServer(server) {
|
|
server.middlewares.use((req, _res, next) => {
|
|
// Rewrite all non-asset requests to libra.html.
|
|
// Strip query before checking for an extension — JWTs (e.g. ?token=...)
|
|
// contain dots and would otherwise get mistaken for an asset request.
|
|
const path = req.url ? req.url.split('?')[0] : ''
|
|
if (
|
|
req.url &&
|
|
!req.url.startsWith('/@') &&
|
|
!req.url.startsWith('/src/') &&
|
|
!req.url.startsWith('/node_modules/') &&
|
|
!path.includes('.')
|
|
) {
|
|
req.url = '/libra.html'
|
|
}
|
|
next()
|
|
})
|
|
},
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Vite config for the standalone Libra accounting app.
|
|
*
|
|
* Set VITE_BASE_PATH to deploy under a path prefix:
|
|
* VITE_BASE_PATH=/libra/ → app.ariege.io/libra/ (shared auth)
|
|
* (default: /) → libra.ariege.io (standalone subdomain)
|
|
*/
|
|
export default defineConfig(({ mode }) => ({
|
|
base: process.env.VITE_BASE_PATH || '/',
|
|
// Per-app dep cache so concurrent dev servers don't race on .vite/deps
|
|
cacheDir: 'node_modules/.vite-libra',
|
|
server: {
|
|
port: 5180,
|
|
strictPort: true,
|
|
},
|
|
plugins: [
|
|
libraHtmlPlugin(),
|
|
vue(),
|
|
tailwindcss(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
devOptions: {
|
|
enabled: false,
|
|
},
|
|
workbox: {
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
|
navigateFallback: 'libra.html',
|
|
navigateFallbackAllowlist: [
|
|
new RegExp(`^${(process.env.VITE_BASE_PATH || '/').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`),
|
|
],
|
|
},
|
|
includeAssets: [
|
|
'favicon.ico',
|
|
'apple-touch-icon.png',
|
|
'mask-icon.svg',
|
|
'icon-192.png',
|
|
'icon-512.png',
|
|
'icon-maskable-192.png',
|
|
'icon-maskable-512.png',
|
|
],
|
|
manifest: {
|
|
name: 'Libra — Team Accounting',
|
|
short_name: 'Libra',
|
|
description: 'Team accounting and expense management',
|
|
theme_color: '#1f2937',
|
|
background_color: '#ffffff',
|
|
display: 'standalone',
|
|
orientation: 'portrait-primary',
|
|
start_url: process.env.VITE_BASE_PATH || '/',
|
|
scope: process.env.VITE_BASE_PATH || '/',
|
|
id: 'libra-accounting',
|
|
categories: ['finance', 'business', 'productivity'],
|
|
lang: 'en',
|
|
icons: [
|
|
{ src: 'icon-192.png', sizes: '192x192', type: 'image/png', purpose: 'any' },
|
|
{ src: 'icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'any' },
|
|
{ src: 'icon-maskable-192.png', sizes: '192x192', type: 'image/png', purpose: 'maskable' },
|
|
{ src: 'icon-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' },
|
|
],
|
|
},
|
|
}),
|
|
ViteImageOptimizer({
|
|
jpg: { quality: 80 },
|
|
png: { quality: 80 },
|
|
webp: { lossless: true },
|
|
}),
|
|
mode === 'analyze' &&
|
|
visualizer({
|
|
open: true,
|
|
filename: 'dist-libra/stats.html',
|
|
gzipSize: true,
|
|
brotliSize: true,
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
// ORDER MATTERS — @rollup/plugin-alias is first-match-wins.
|
|
// The more specific @/app.config remap must precede the @ prefix
|
|
// alias, otherwise '@/app.config' matches '@' first and resolves
|
|
// to ./src/app.config (the hub config). ExpensesAPI etc. import
|
|
// from @/app.config and need the per-app config.
|
|
'@/app.config': fileURLToPath(new URL('./src/accounting-app/app.config.ts', import.meta.url)),
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'dist-libra',
|
|
rollupOptions: {
|
|
input: 'libra.html',
|
|
output: {
|
|
manualChunks: {
|
|
'vue-vendor': ['vue', 'vue-router', 'pinia'],
|
|
'ui-vendor': ['radix-vue', '@vueuse/core'],
|
|
'shadcn': ['class-variance-authority', 'clsx', 'tailwind-merge'],
|
|
},
|
|
},
|
|
},
|
|
chunkSizeWarningLimit: 1000,
|
|
},
|
|
}))
|