cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.7k stars 709 forks source link

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

Open Ehesp opened 1 year ago

Ehesp commented 1 year ago

Describe the solution

Given the following, where there's a custom build flow:

[build]
command = "custom_cli build"

I'd like to be able to detect whether wrangler dev or wrangler publish has triggered the command, as to do some custom logic in the build command. As far as I can see, it is not possible to detect this at all.

I also tried defining .dev.vars but it seems this is loaded after the custom build command, so I can't use that to detect the environment.

Ehesp commented 1 year ago

Ah this might be what I'm looking for: https://github.com/cloudflare/miniflare/issues/116

I'll give it a try and see if it solves the issue.

EDIT: Ah no, this isn't the same. This still expects a --env flag in the wrangler command vs being automatic.