Skip to content

[wrangler] Add WRANGLER_COMMAND environment variable to custom build commands#12470

Merged
petebacondarwin merged 1 commit intomainfrom
fix/2634-detect-dev-publish
Feb 9, 2026
Merged

[wrangler] Add WRANGLER_COMMAND environment variable to custom build commands#12470
petebacondarwin merged 1 commit intomainfrom
fix/2634-detect-dev-publish

Conversation

@petebacondarwin
Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin commented Feb 7, 2026

Fixes #2634.

When using a custom build command in wrangler.toml, users can now detect whether wrangler dev or wrangler deploy triggered the build by reading the WRANGLER_COMMAND environment variable.

This variable will be set to "dev", "deploy", "versions upload", or "types" depending on which command invoked the build. This allows customizing the build process based on the deployment context.

Example usage in a build script:

if [ "$WRANGLER_COMMAND" = "dev" ]; then
  echo "Building for development..."
else
  echo "Building for production..."
fi

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation

A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: 511eae8

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 7, 2026

Claude finished @petebacondarwin's task —— View job


Changeset Review Complete

✅ All changesets look good

The changeset in .changeset/wrangler-command-env-var.md is well-formatted and follows all guidelines:

  1. Version Type: Correctly marked as minor (new feature - new environment variable)
  2. Changelog Quality: Clear, descriptive title and body with practical usage example
  3. Markdown Headers: No h1/h2/h3 headers used ✓
  4. Analytics: No analytics changes
  5. Experimental features: Not applicable

The changeset provides excellent documentation including:

  • Clear explanation of what the feature does
  • Complete list of possible values ("dev", "deploy", "versions upload", "types")
  • Practical bash script example showing how to use it

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 7, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12470

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12470

miniflare

npm i https://pkg.pr.new/miniflare@12470

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12470

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12470

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12470

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12470

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12470

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12470

wrangler

npm i https://pkg.pr.new/wrangler@12470

commit: 511eae8

@petebacondarwin petebacondarwin mentioned this pull request Feb 7, 2026
5 tasks
@petebacondarwin petebacondarwin marked this pull request as ready for review February 7, 2026 14:47
@petebacondarwin petebacondarwin requested a review from a team as a code owner February 7, 2026 14:47
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

When using a custom build command in wrangler.toml, users can now detect
whether wrangler dev or wrangler deploy triggered the build by reading the
WRANGLER_COMMAND environment variable.

This variable will be set to 'dev', 'deploy', 'versions upload', or 'types'
depending on which command invoked the build. This allows customizing
the build process based on the deployment context.

Fixes #2634
@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Feb 9, 2026
@petebacondarwin petebacondarwin merged commit 21ac7ab into main Feb 9, 2026
36 of 37 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Feb 9, 2026
@petebacondarwin petebacondarwin deleted the fix/2634-detect-dev-publish branch February 9, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: Detect dev/publish during custom build command

3 participants