Skip to content

Conversation

@petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Nov 9, 2025

Summary

This PR documents the new CLOUDFLARE_ENV environment variable feature for Wrangler, which allows users to select environments without using the --env flag. This feature is being added in workers-sdk PR #11228.

Changes made:

  • Added CLOUDFLARE_ENV to the system environment variables documentation with usage examples
  • Updated the environments documentation to mention the new environment variable as an alternative to the --env flag
  • Created a changelog entry documenting the feature with examples and use cases

Key points for reviewers:

  • ⚠️ Changelog date: The changelog is dated 2025-11-09, but should be updated to match the actual release date when the feature ships in Wrangler
  • ⚠️ Command syntax: The build tool example uses & to run commands in parallel (npm run build & wrangler deploy). Please verify this is the intended behavior vs && for sequential execution, given the context suggests the environment should be set once and used for both operations
  • The --env command line argument takes precedence over the CLOUDFLARE_ENV environment variable (documented consistently across all three locations)
  • The feature is particularly useful with build tools like @cloudflare/vite-plugin where the environment needs to be consistent between build and deploy
  • All internal links should be verified to ensure they point to the correct documentation sections

Documentation checklist

  • Is there a changelog entry (guidelines)?
  • The change adheres to the documentation style guide.
  • If a larger change - such as adding a new page- an issue has been opened in relation to any incorrect or out of date information that this PR fixes.
  • Files which have changed name or location have been allocated redirects.

Link to Devin run: https://app.devin.ai/sessions/fc5ba87ae01f4b21ae0916c0e67beddc
Requested by: @petebacondarwin
Related PR: cloudflare/workers-sdk#11228

- Add CLOUDFLARE_ENV to system environment variables documentation
- Update environments documentation to mention CLOUDFLARE_ENV usage
- Add changelog entry for the new feature

Related to cloudflare/workers-sdk#11228

Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2025

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/changelog/ @cloudflare/pm-changelogs, @cloudflare/pcx-technical-writing
/src/content/docs/workers/wrangler/ @cloudflare/wrangler, @irvinebroque, @kodster28, @cloudflare/pcx-technical-writing, @cloudflare/workers-runtime-1

Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
CLOUDFLARE_ENV=production npm run build & wrangler deploy
```

When using `@cloudflare/vite-plugin`, the build process generates a "redirected deploy config" that is flattened to only contain the active environment. Wrangler will validate that the environment specified matches the environment used during the build to prevent accidentally deploying a Worker built for one environment to a different environment.
Copy link
Contributor

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Good suggestion! Added the link to the generated wrangler configuration documentation.

Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants