radix
Explore posts from serversCDCloudflare Developers
•Created by radix on 11/27/2023 in #workers-help
Is it possible to run a different build command based on whether you're doing `wrangler dev/deploy`
I'm using workers-rs, and my wasm build takes a very long time in release mode, to the point where it's too slow for rapid iteration in local development. It's much better if I build in dev mode.
The default build command in wrangler.toml is:
I can change the
--release
to --dev
, which results in much faster build times, but then I might forget about it and accidentally upload an unoptimized .wasm file to production.
I have been experimenting to try to figure out if there's a way to know whether wrangler is being run in dev or deploy modes inside the build
command. I was hoping I could read an environment variable and change the behavior of my build command, but I can't see any environment variables that change based on dev or deploy. I've noticed that wrangler apparently has some support for reading .env files (there is an -e
parameter to the wrangler dev cli), but I have not been able to get that to work -- I don't see any custom defined environment variables inside a build command environment (tested by changing my build command to set
).2 replies