You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workers/wrangler/configuration.mdx
+88-1Lines changed: 88 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1191,7 +1191,7 @@ upload_source_maps = true
1191
1191
1192
1192
## Workers Sites
1193
1193
1194
-
<Renderfile="workers_sites"/>
1194
+
<Renderfile="workers_sites"/>
1195
1195
1196
1196
[Workers Sites](/workers/configuration/sites/) allows you to host static websites, or dynamic websites using frameworks like Vue or React, on Workers.
1197
1197
@@ -1252,3 +1252,90 @@ If you change your environment variables in the Cloudflare dashboard, Wrangler w
1252
1252
If you change your routes in the dashboard, Wrangler will override them in the next deploy with the routes you have set in your Wrangler configuration file. To manage routes via the Cloudflare dashboard only, remove any route and routes keys from your Wrangler configuration file. Then add `workers_dev = false` to your Wrangler configuration file. For more information, refer to [Deprecations](/workers/wrangler/deprecations/#other-deprecated-behavior).
1253
1253
1254
1254
Wrangler will not delete your secrets (encrypted environment variables) unless you run `wrangler secret delete <key>`.
1255
+
1256
+
## Generated Wrangler configuration
1257
+
1258
+
:::note
1259
+
1260
+
This section describes a feature that can be implemented by frameworks and other build tools that are integrating with Wrangler.
1261
+
1262
+
It is unlikely that an application developer will need to use this feature, but it is documented here to help you understand when Wrangler is using a generated configuration rather than a user's configuration.
1263
+
1264
+
:::
1265
+
1266
+
When using a framework or a custom pre-build process, some tools need to generate a modified Wrangler configuration alongside the generated code.
1267
+
In this case, the tool may also create a special `.wrangler/deploy/config.json` file that redirects Wrangler to use the generated configuration rather than the original user configuration.
1268
+
1269
+
Wrangler uses this generated configuration only for the following deploy and dev related commands:
1270
+
1271
+
-`wrangler deploy`
1272
+
-`wrangler dev`
1273
+
-`wrangler versions upload`
1274
+
-`wrangler versions deploy`
1275
+
-`wrangler pages deploy`
1276
+
-`wrangler pages build`
1277
+
-`wrangler pages build-env`
1278
+
1279
+
When running these commands, Wrangler looks up the directory tree from the current working directory for a file at the path `.wrangler/deploy/config.json`.
1280
+
This file must contain only a single JSON object of the form:
1281
+
1282
+
```json
1283
+
{ "configPath": "../../path/to/wrangler.json" }
1284
+
```
1285
+
1286
+
When this `config.json` file exists Wrangler will follow the `configPath` (relative to the `.wrangler/deploy/config.json` file) to find the generated Wrangler configuration file to load and use in the current command.
1287
+
Wrangler will display messaging to the user to indicate that the configuration has been redirected to a different file than the user's configuration file.
1288
+
1289
+
### Custom build tool example
1290
+
1291
+
A common approach that a build tool might choose to implement is to output code and configuration in a `dist` directory.
1292
+
1293
+
- The user writes code that uses Cloudflare Workers resources, configured via a user `wrangler.toml` file.
1294
+
1295
+
```toml
1296
+
name = "my-worker"
1297
+
main = "src/index.ts"
1298
+
[[kv_namespaces]]
1299
+
binding = "<BINDING_NAME1>"
1300
+
id = "<NAMESPACE_ID1>"
1301
+
```
1302
+
1303
+
Note that this configuration points `main` at the user code entry-point.
1304
+
1305
+
- The user runs a custom build, which might read the user's `wrangler.toml` to find the source code entry-point:
1306
+
1307
+
```bash
1308
+
> my-tool build
1309
+
```
1310
+
1311
+
- This `my-tool` generates a `dist` directory that contains both compiled code and a new deployment configuration file.
1312
+
It also generates a `.wrangler/deploy/config.json` file that redirects Wrangler to the new generated deployment configuration file:
0 commit comments