mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #70] [MERGED] fix(dotenv): load .env files with Next.js precedence #288
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#288
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/70
Author: @southpolesteve
Created: 2/25/2026
Status: ✅ Merged
Merged: 2/25/2026
Merged by: @southpolesteve
Base:
main← Head:fix/dotenv-review-fixes📝 Commits (3)
63c1ba8feat(cli): load .env files with Next.js precedence6b5590ffix(dotenv): address review feedback on .env loadinge900128test(dotenv): add cross-file expansion and multi-line value tests📊 Changes
6 files changed (+461 additions, -1 deletions)
View changed files
📝
AGENTS.md(+17 -0)📝
README.md(+30 -1)📝
packages/vinext/src/cli.ts(+16 -0)➕
packages/vinext/src/config/dotenv.ts(+132 -0)📝
packages/vinext/src/deploy.ts(+2 -0)➕
tests/dotenv.test.ts(+264 -0)📄 Description
Summary
Closes #24. Supersedes #46 (takes over @liuxiaopai-ai's work and addresses review feedback).
Adds automatic
.envfile loading with Next.js-compatible precedence for all CLI commands (dev,build,start,deploy).Load order (highest priority first)
process.envvalues (shell/CI).env.<mode>.local.env.local(skipped intestmode).env.<mode>.envSecurity model
NEXT_PUBLIC_*vars are inlined into client bundles via Vite'sdefine(the existinggetNextPublicEnvDefines()mechanism). Non-public vars stay server-only.next.config.jsenvproperty still bypasses the prefix filter (matches Next.js behavior).$VAR/${VAR}) supported with cycle detection.Changes from PR #46
process.envfor server-side access; Vite populatesimport.meta.env.VITE_*for its own system)\$100was not being unescaped because$followed by a digit doesn't match the variable-name regexparseEnvreturn valueloadedEnvassertions, production mode precedence,${VAR}expansion syntax, escaped dollars, circular references, missing files, empty result,getDotenvFilesfor all modesnode:utilparseEnvrather thandotenvpackage)Co-authored-by: liuxiaopai-ai liuxiaopai-ai@users.noreply.github.com
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.