Remove env-config.js (#9331)
Fixes #5340 which had been open for a long time
This commit is contained in:
@ -1,12 +1,25 @@
|
||||
#!/bin/sh
|
||||
echo "Generating env-config.js file from runtime environment variables..."
|
||||
|
||||
BASE_FILENAME="build/env-config.js"
|
||||
mkdir -p build
|
||||
rm -rf "./$BASE_FILENAME"
|
||||
echo "Injecting runtime environment variables into index.html..."
|
||||
|
||||
{
|
||||
echo "window._env_ = {"
|
||||
echo " REACT_APP_SERVER_BASE_URL: \"$REACT_APP_SERVER_BASE_URL\","
|
||||
echo "}"
|
||||
} > "./$BASE_FILENAME"
|
||||
CONFIG_BLOCK=$(cat << EOF
|
||||
<script id="twenty-env-config">
|
||||
window._env_ = {
|
||||
REACT_APP_SERVER_BASE_URL: "$REACT_APP_SERVER_BASE_URL"
|
||||
};
|
||||
</script>
|
||||
<!-- END: Twenty Config -->
|
||||
EOF
|
||||
)
|
||||
# Use sed to replace the config block in index.html
|
||||
# Using pattern space to match across multiple lines
|
||||
sed -i.bak '
|
||||
/<!-- BEGIN: Twenty Config -->/,/<!-- END: Twenty Config -->/{
|
||||
/<!-- BEGIN: Twenty Config -->/!{
|
||||
/<!-- END: Twenty Config -->/!d
|
||||
}
|
||||
/<!-- BEGIN: Twenty Config -->/r /dev/stdin
|
||||
/<!-- END: Twenty Config -->/d
|
||||
}
|
||||
' build/index.html <<< "$CONFIG_BLOCK"
|
||||
rm -f build/index.html.bak
|
||||
|
||||
Reference in New Issue
Block a user