Is there a particular plugin you need that is not available for esbuild?
A lot can be accomplished with esbuild which vite wraps anyway. Vite whilst faster than most bundlers (due to esbuild) is still slower than just using esbuild.
I’ve recently setup a similar stack. I found these guide to be extremely helpful and kind of picked and chose between both similar approaches.
Basically, I set things up in frontend folder, but could also have been in the assets folder too. I run Vite in a separate process (using the mix watchers) on port 3000, with Vite dev server producing requests to port 4000 where phoenix is running. 90% of the time I access the app on port 3000 (Vite) during development.
I also have the Vite production build copy directly to the phoenix assets directory and can easily do a build and access the full app on port 4000 at any time. I have a catch all controller that serves up the dist index.html file.
I’m very comfortable with React and the tool chains and find myself very productive, though phoenix is really just acting as an API server for now.
I was sort of hoping to have a phoenix watcher for vite but by doing so there’s no HMR as far as i could tell. It did work in another process but I didn’t want 2 terminal windows in dev.
This explains the reload approach in Phoenix with LiveView:
Now the OP didn’t mention liveview, however in Phoenix app the state is managed on the server so it will trigger a reload to get the updated state and render using the new code.
If it’s not Pheonix LiveView then HMR will probably be required to not lose the state held on the client.