Files
explore/deploy/scripts/make_envs_script.sh
T
tom goriunovandGitHub 811ba0a437 Move generated assets into separate folder inside the public folder (#1930)
* add build-time ENV to explicitly enable Open Telemetry

* generate svg-sprite before next build

* move envs.js to assets folder

* move favicon bundle to assets folder

* move external configs to configs folder

* fix envs validator
2024-05-20 13:17:33 +02:00

34 lines
745 B
Bash
Executable File

#!/bin/bash
echo "🌀 Creating client script with ENV values..."
# Define the output file name
output_file="${1:-./public/assets/envs.js}"
touch $output_file;
truncate -s 0 $output_file;
# Check if the .env file exists and load ENVs from it
if [ -f .env ]; then
source .env
export $(cut -d= -f1 .env)
fi
echo "window.__envs = {" >> $output_file;
# Iterate through all environment variables
for var in $(env | grep '^NEXT_PUBLIC_' | cut -d= -f1); do
# Get the value of the variable
value="${!var}"
# Replace double quotes with single quotes
value="${value//\"/\'}"
# Write the variable name and value to the output file
echo "${var}: \"${value}\"," >> "$output_file"
done
echo "}" >> $output_file;
echo "✅ Done."