feat(webapp): restaurant bundle skeleton
Standalone customer-facing bundle for the LNbits 'restaurant' extension, modeled on the market bundle. v1 ships single-venue (URL-driven via /r/:slug) with REST-only order placement; festival aggregator and NIP-17 transport are tracked as aiolabs/restaurant#8 and #9 respectively. Skeleton this commit lands: vite.restaurant.config.ts — port 5186, dist-restaurant/, green theme color, PWA manifest, alias @/app.config -> restaurant-app/. restaurant.html — entry; title 'Restaurant — Order'. src/restaurant-app/ main.ts — startApp + PWA SW registration. app.ts — module registration glue (baseModule + restaurantModule). app.config.ts — modules.restaurant config block. Reserves a features:{} slot for tier-gated UI (aiolabs/restaurant#2). App.vue — AppShell with Browse / Cart / Orders bottom-nav tabs. src/modules/restaurant/ index.ts — ModulePlugin shell with the future- roadmap context inlined as top-of-file comment (#1..#9). views/HomePage.vue — placeholder; commit 4 replaces it with real discovery + redirect. src/core/di-container.ts — RESTAURANT_API + RESTAURANT_NOSTR_SYNC tokens reserved (consumers land in 3 / 8). package.json — dev:restaurant, build:restaurant, preview:restaurant scripts and append to dev:all + build:demo. Verified: - vue-tsc -b passes (whole webapp, all bundles). - vite build --config vite.restaurant.config.ts builds clean against VITE_LNBITS_BASE_URL=http://localhost:5001 VITE_RESTAURANT_DEFAULT_SLUG=big-jays-bustaurant. - vite dev server boots on :5186 and serves the entry. Companion branch: extension repo aiolabs/restaurant on branch feat/restaurant-by-slug already provides GET /restaurants/by-slug/{slug} that the webapp will consume in commit 3.
This commit is contained in:
parent
7bc92e21b8
commit
41fbad3d90
10 changed files with 526 additions and 2 deletions
132
vite.restaurant.config.ts
Normal file
132
vite.restaurant.config.ts
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
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'
|
||||
|
||||
function restaurantHtmlPlugin(): Plugin {
|
||||
return {
|
||||
name: 'restaurant-html-rewrite',
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, _res, next) => {
|
||||
// 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 = '/restaurant.html'
|
||||
}
|
||||
next()
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vite config for the standalone Restaurant customer app.
|
||||
*
|
||||
* Set VITE_BASE_PATH to deploy under a path prefix:
|
||||
* VITE_BASE_PATH=/restaurant/ → app.${domain}/restaurant/ (shared auth)
|
||||
* (default: /) → restaurant.${domain} (standalone subdomain)
|
||||
*
|
||||
* The companion server is the LNbits "restaurant" extension at
|
||||
* ~/dev/shared/extensions/restaurant. v1 ships single-venue (URL-driven
|
||||
* via /r/:slug); festival/aggregator and NIP-17 transport are tracked
|
||||
* in repo issues #8 and #9 on aiolabs/restaurant.
|
||||
*/
|
||||
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-restaurant',
|
||||
server: {
|
||||
port: 5186,
|
||||
strictPort: true,
|
||||
},
|
||||
plugins: [
|
||||
restaurantHtmlPlugin(),
|
||||
vue(),
|
||||
tailwindcss(),
|
||||
VitePWA({
|
||||
registerType: 'autoUpdate',
|
||||
devOptions: { enabled: false },
|
||||
workbox: {
|
||||
globPatterns: ['**/*.{js,css,html,ico,png,svg}'],
|
||||
navigateFallback: 'restaurant.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: 'Restaurant — Order',
|
||||
short_name: 'Restaurant',
|
||||
description: 'Order from your local Nostr-native restaurant with Lightning payments',
|
||||
// Green to differentiate from market red. PDF tile is purple
|
||||
// (see ~/dev/shared/extensions/restaurant/static/image/restaurant.png).
|
||||
theme_color: '#16a34a',
|
||||
background_color: '#ffffff',
|
||||
display: 'standalone',
|
||||
orientation: 'portrait-primary',
|
||||
start_url: process.env.VITE_BASE_PATH || '/',
|
||||
scope: process.env.VITE_BASE_PATH || '/',
|
||||
id: 'restaurant-app',
|
||||
categories: ['food', 'shopping'],
|
||||
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-restaurant/stats.html',
|
||||
gzipSize: true,
|
||||
brotliSize: true,
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
// ORDER MATTERS — @/app.config must precede @ (first-match-wins).
|
||||
'@/app.config': fileURLToPath(new URL('./src/restaurant-app/app.config.ts', import.meta.url)),
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist-restaurant',
|
||||
rollupOptions: {
|
||||
input: 'restaurant.html',
|
||||
output: {
|
||||
manualChunks: {
|
||||
'vue-vendor': ['vue', 'vue-router', 'pinia'],
|
||||
'ui-vendor': ['radix-vue', '@vueuse/core'],
|
||||
'shadcn': ['class-variance-authority', 'clsx', 'tailwind-merge'],
|
||||
},
|
||||
},
|
||||
},
|
||||
chunkSizeWarningLimit: 1000,
|
||||
},
|
||||
}))
|
||||
Loading…
Add table
Add a link
Reference in a new issue