#!/bin/sh # 生成环境变量配置文件 echo "window.ENV = {" > ./dist/env-config.js # 注入 BASE_URL 环境变量 if [ -n "$BASE_URL" ]; then echo " BASE_URL: '$BASE_URL'," >> ./dist/env-config.js fi # 添加其他环境变量,如有需要 # if [ -n "$API_KEY" ]; then # echo " API_KEY: '$API_KEY'," >> ./dist/env-config.js # fi # 关闭对象 echo "};" >> ./dist/env-config.js # 确保 env-config.js 被引入到 index.html sed -i "s/<\/head>/\n