build(frontend): keep a developer's .env.production.local across the UI build

The script copied .env.development over frontend/.env.production.local and
deleted it on exit, destroying a local override. An existing file is now
set aside before the build and put back by the exit trap, whatever the
build's outcome; without one, nothing is left behind.
This commit is contained in:
Alex committed 2026-09-09 11:26:16 +01:00
1 parent 43f493b926
commit 6dead25508
1 file changed
+15 -1
+15 -1
View File
@@ -19,8 +19,22 @@ fi
# As in frontend/Dockerfile: the committed .env.development is the baseline
# of the production build. The API rewrites VITE_API_HOST and VITE_BASE_URL
# at runtime through /config.js, so those baked values never reach a browser.
# A developer's own .env.production.local is set aside for the build and put
# back afterwards, whatever happens in between.
saved_override=""
if [ -e .env.production.local ] || [ -L .env.production.local ]; then
saved_override="$(mktemp "${TMPDIR:-/tmp}/docsgpt-env-production-local.XXXXXX")"
cp -p .env.production.local "$saved_override"
fi
restore_override() {
if [ -n "$saved_override" ]; then
mv -f "$saved_override" .env.production.local
else
rm -f .env.production.local
fi
}
trap restore_override EXIT
cp .env.development .env.production.local
trap 'rm -f .env.production.local' EXIT
npm run build
# Load the runtime config ahead of the bundle, as the nginx image does.