Suggestion: backend-only mode
Description
I recently started working on a new project. It's a backend-only project, using express.
Almost by reflex, I tried using Vite for it, when I realised that's not what Vite is for. But why wouldn't it? It has a lot of features I love and need:
- plugins - import glob, directly import various resources (e.g. yaml configuration files), etc.
- dev server - I don't need a front-end, but I'd love to be able to run my app, change something, and it instantly restarts; no build needed
- testing - amazing test runner and just works with my plugins/build pipeline
- build - self-explanatory
- environment variables & modes
- serving static files
Suggested solution
I'd love a simple, official Vite plugin for backend-only apps. It creates a single environment (no client vs. ssr), with dev and build commands that work with the standard plugins & Vitest.
I feel like this makes sense now more than ever with Vite Plus, which offers so much more than dev and build. Vite was created as a tool for web developers, but with how popular and feature-rich it is now, and with the new environments API meant to support more than just client + SSR mode, this feature really feels like a missing puzzle piece.
Alternative
I ended up using rolldown directly, with rolldown & node watch mode for the dev server, and making the pipeline work with Vitest, which was quite a bit of work, and is not perfect.
There also are third-party plugins like vite-express, but I think an official, generic solution would be all-around very useful.
In short, there is a bit of friction, which a minimalist Vite plugin could easily get around. I don't see why Vite(+) with such a plugin wouldn't be used for non-web work, even if just as a light wrapper over rolldown to simplify the setup & improve the experience.
Additional context
If this sounds like a good idea, I'm happy to work on & try contributing this feature
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Source: vitejs/vite