I tried the proposed answer but it didn't work for me as I'm using nextjs and firebase. I had to modify the package.json with a new script
"deploy-hosting-preprod": "sed -i '.bak' 's/NEXT_PUBLIC_ENVIRONMENT=.*/NEXT_PUBLIC_ENVIRONMENT=live/' .env; export NEXT_PUBLIC_ENVIRONMENT=live; firebase deploy --only hosting:preprod"
Also in my firebase json instead of using predeploy I use postdeploy, to return the .env file to normal as:
{
"hosting": [
...
{
"target": "preprod",
"source": ".",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"postdeploy": ["npm run revert-env"]
}
],
...