Custom builds
Custom builds are a way for you to customize how your code is compiled, before being processed by Wrangler.
Configure custom builds
Custom builds are configured by adding a [build] section in your wrangler.toml, and using the following options for configuring your custom build.
commandstring- The command used to build your Worker. On Linux and macOS, the command is executed in the
shshell and thecmdshell for Windows. The&&and||shell operators may be used. This command will be run as part ofwrangler devandnpx wrangler deploy.
- The command used to build your Worker. On Linux and macOS, the command is executed in the
cwdstring- The directory in which the command is executed.
watch_dirstring | string[]- The directory to watch for changes while using
wrangler dev. Defaults to the current working directory.
- The directory to watch for changes while using
Example:
[build]
command = "npm run build"
cwd = "build_cwd"
watch_dir = "build_watch_dir"
// For Wrangler to read a JSON configuration file, you must add the `-j` flag
// e.g. `wrangler -j dev`
{ "build": { "command": "npm run build", "cwd": "build_cwd", "watch_dir": "build_watch_dir" }
}