Skip to content

fix: honor build --mode dotenv files#2523

Open
WilliamK112 wants to merge 2 commits into
cloudflare:mainfrom
WilliamK112:codex/build-mode-dotenv-2393
Open

fix: honor build --mode dotenv files#2523
WilliamK112 wants to merge 2 commits into
cloudflare:mainfrom
WilliamK112:codex/build-mode-dotenv-2393

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

Closes #2393.

This adds Vite-style vinext build --mode <mode> support for build-time dotenv loading:

  • parse --mode / --mode=<mode> in the shared CLI parser
  • load .env.<mode>* through vinext's Next-compatible dotenv loader before Vite config/build setup
  • pass the same mode into Vite config metadata loading, createBuilder, and the hybrid Pages Router server build
  • allow custom dotenv modes such as staging/cdn while preserving the existing test-mode .env.local skip
  • document the build flag in vinext build --help

Validation

  • corepack pnpm test tests/cli-args.test.ts tests/dotenv.test.ts (75/75)
  • corepack pnpm exec tsc --noEmit --pretty false --project packages/vinext/tsconfig.json
  • corepack pnpm run check
  • corepack pnpm --filter vinext build
  • git diff --check origin/main...HEAD
  • Manual smoke: built a temporary Pages fixture with .env, .env.production, and .env.staging, ran node packages/vinext/dist/cli.js build --mode staging, and verified every vite.config load saw mode: "staging" plus process.env.NEXT_PUBLIC_TARGET === "from-staging" before the build completed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6aa2d19e3b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/vinext/src/cli.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom --mode dotenv loading for vinext build

1 participant