groupchat/client/vite.config.js
Jason Tudisco 6cb423b342 feat: add database backup on startup and isolate dev environment
Add automatic SQLite database backup before migrations on every server
start. Backups are timestamped and stored in backups/, with WAL/SHM
files included. Old backups are pruned to keep only the 10 most recent.

Update dev.sh to use separate ports and database from production so both
can run simultaneously on the same machine:
  - Production: server :3001, DB chat.db
  - Development: server :3002, Vite :3003, DB chat-dev.db

Make Vite config dynamic via VITE_PORT and VITE_API_PORT env vars.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:27:32 -06:00

44 lines
939 B
JavaScript

import { defineConfig } from 'vite'
// Custom Riot.js plugin for Vite
function riotPlugin() {
return {
name: 'vite-plugin-riot',
async transform(code, id) {
if (!id.endsWith('.riot')) return null
const { compile } = await import('@riotjs/compiler')
const { code: compiled } = compile(code, { file: id })
return {
code: compiled,
map: null,
}
},
}
}
const apiPort = process.env.VITE_API_PORT || '3001'
const clientPort = parseInt(process.env.VITE_PORT || '3000')
export default defineConfig({
plugins: [riotPlugin()],
server: {
port: clientPort,
proxy: {
'/api': {
target: `http://localhost:${apiPort}`,
changeOrigin: true,
},
'/ws': {
target: `ws://localhost:${apiPort}`,
ws: true,
},
'/uploads': {
target: `http://localhost:${apiPort}`,
changeOrigin: true,
},
},
},
})