Ionic live serve with vite mode

How can I use the ionic cap run android -l --external command with a custom Vite mode?
For example, my mode is called foo and I have a .env.foo file.
The command ionic cap run android -l --external --mode foo doesn’t work, and neither does ionic cap run android -l --external -- --mode foo.

Have you tried:

NODE_ENV=foo ionic cap run android -l --external

See Env Variables and Modes | Vite