#!/bin/bash

# Recreate config file
rm -rf ./env-config.js
touch ./env-config.js

# Add assignment 
echo "window._env_ = {" >> ./env-config.js

# List of environment variables to export (add more as needed)
ENV_VARS="API_URL PUBLIC_HOST INTERNAL_HOST"

# Read each environment variable and add to config
for varname in $ENV_VARS; do
  # Get value from environment using indirect expansion
  value="${!varname}"
  
  # Only add if value exists
  if [ -n "$value" ]; then
    echo "  $varname: \"$value\"," >> ./env-config.js
  fi
done

echo "}" >> ./env-config.js
