vite-plugin-to-express

/home/avalon/.hermes/skills/software-development/vite-plugin-to-express/SKILL.md · raw

Vite Plugin API → Express Production Server

Trigger

Steps

  1. Identify the Vite plugin API file — usually registers routes via configureServer hook
  2. Create server.js (or server.ts) standalone Express app: - Copy all route handlers from the Vite plugin - Replace Vite middleware patterns with Express app.get/post/put/delete - Add express.static('dist') to serve the built frontend - Add catch-all route for SPA: app.get('/{*splat}', ...) (Express 5) or app.get('*', ...) (Express 4)
  3. Build frontend: npm run build → produces dist/
  4. Database connection: Keep the same pg Pool config, just update host/port for production
  5. Run with PM2: pm2 start server.js --name app-name

Pitfalls

Verification

curl http://localhost:PORT/api/health  # API responds
curl http://localhost:PORT/             # Frontend HTML served