Another option would be to have your build command build both versions of your site and put them in a subfolder in your publish directory (for example, /public/en
and /public/es
). If you have both subdomains added as domain aliases to you site, you can then create _redirects file to serve the proper language based on the subdomain.
Like:
https://en.example.com/* /en/:splat 200
https://es.example.com/* /es/:splat 200
This would allow you to have a single site with two language version served on different subdomains. You can even try using language-based redirects on top of the redirect I mentioned. Let me know what you think.