add docker support
This commit is contained in:
22
.docker/env.sh
Normal file
22
.docker/env.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/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<script src=\"\/env-config.js\"><\/script>\n<\/head>/g" ./dist/index.html
|
||||
|
||||
echo "环境变量已注入到 dist/env-config.js 并已在 index.html 中引入"
|
Reference in New Issue
Block a user