Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/content/docs/workers/wrangler/custom-builds.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,29 @@ Example:
```

</WranglerConfig>

## `WRANGLER_COMMAND` environment variable

When Wrangler runs your custom build command, it sets the `WRANGLER_COMMAND` environment variable so your build script can detect which Wrangler command triggered the build. This allows you to customize the build process based on the deployment context.

The possible values are:

| Value | Wrangler command triggered |
| ------------------ | ---------------------------------------- |
| `dev` | `wrangler dev` |
| `deploy` | `wrangler deploy` |
| `versions upload` | `wrangler versions upload` |
| `types` | `wrangler types` |

For example, you can use this to apply different build settings for development and production:

```bash
#!/bin/bash
if [ "$WRANGLER_COMMAND" = "dev" ]; then
echo "Building for development..."
# run a development build
else
echo "Building for production..."
# run a production build
fi
```
Loading