wrangler custom build commands receive WRANGLER_COMMAND
Introduced 2026-02-10 · score 0.93
HOW TO USE IT
When Wrangler runs a configured custom build command, branch on `WRANGLER_COMMAND` to select the build behavior for `dev`, `deploy`, `versions upload`, or `types`.
[build]
command = "./build.sh"if [ "$WRANGLER_COMMAND" = "dev" ]; then
echo "Building for development..."
else
echo "Building for production..."
fiWHY THIS HELPS
Branch a custom build script on whether Wrangler invoked it for development, deployment, versions upload, or types.
REQUIREMENTS AND LIMITATIONS
- Version: 4.64.0
- build.command: Command used to build the Worker; it runs as part of Wrangler commands that trigger the custom build.
- WRANGLER_COMMAND: Environment variable set for the custom build; values documented are `dev`, `deploy`, `versions upload`, and `types`.
- Prerequisite: Configure a custom build command in the Wrangler configuration file.
- The variable applies when using a custom build command in `wrangler.toml`.
FIRST-PARTY EVIDENCE
- https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.64.0
- https://developers.cloudflare.com/workers/wrangler/custom-builds/
Check the installed version and the source before using it. Entry JSON