enrollment-app/build_web_production.sh
2024-07-16 17:37:24 +05:30

43 lines
920 B
Bash
Executable File

#!/bin/bash
# Define the path to the .env.production file
ENV_FILE_PATH=".env.production"
# Check if the .env.production file exists
if [ ! -f $ENV_FILE_PATH ]; then
echo "$ENV_FILE_PATH does not exist"
exit 1
fi
# Copy the .env.production file to .env
cp $ENV_FILE_PATH .env
echo "Copied $ENV_FILE_PATH to .env"
# Verify .env file contains correct values
source .env
if [ -z "$BASE_HREF" ]; then
echo "BASE_HREF value is empty"
exit 1
fi
if [ -z "$API_URL" ]; then
echo "API_URL value is empty"
exit 1
fi
# Print loaded values for verification
echo "Loaded BASE_HREF: $BASE_HREF"
echo "Loaded API_URL: $API_URL"
# Build the web app for production with base href
flutter build web --release --base-href "$BASE_HREF" --dart-define=ENV=production
# Check if the build was successful
if [ $? -ne 0 ]; then
echo "Flutter production build failed"
exit 1
fi
echo "Flutter production build succeeded"