We like to use Dart both for frontend and backend.
The normal way looks to use pub as build tool. Pub serve, and pub build. We will use extra transformers to compiles less to css on the fly, for css autoprefxing, etc. The nice thing is that during development this happens in memory with pub serve. For production the compilation is done once and saved in a build directory. When changing a file the pub serve detects it, nice!
However this commands don't start the backend Dart code. It seems a bit strange to start two different processes when both are dart processes.
The backend should serve the frontend, serve the REST api, serve websockets, handle caching, business logic etc.
We would like to run them on the same network port, both during develpment and production.
So the question is how to solve this:
A: Implement the server functionality as transformer. pub serve can load this to start the backend. For production we create a dart file with a custom http server based on package:http_server and add the other server functionality by adding the transformers.
In this case it feels strange to implement all backend functionality as transformers. Some backend functionality will not serve anything at all, so not really a transformer case.
B: Create our own pub serve functionality in the backend Always start our own backend and include a command line option for development. This means implementing some features that are in pub serve into our backend: detect changes, compile dart to js, less to css, css autoprefixer, .... Feels like recreating what already exists.
C: Better options?