Script is using here-string <<< which is not supported by sh, using bash instead Also removing "sh" from the command to actually use the bash from the shebang
26 lines
708 B
Bash
Executable File
26 lines
708 B
Bash
Executable File
#!/bin/bash
|
|
|
|
echo "Injecting runtime environment variables into index.html..."
|
|
|
|
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
|