Skip to content

Commit f5b409f

Browse files
[docs] update wrangler.toml example to wrangler@2 (#5187)
* fix: update wrangler.toml example to wrangler@2 Updates the example provided for `wrangler.toml` file for the `adapter-cloudflare-workers` documentation, to follow the specs on wrangler@2. * align README with the error message printed when wrangler.toml is missing * changeset Co-authored-by: Rich Harris <[email protected]>
1 parent a48a30d commit f5b409f

File tree

3 files changed

+24
-40
lines changed

3 files changed

+24
-40
lines changed

.changeset/hip-kangaroos-check.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/adapter-cloudflare-workers': patch
3+
---
4+
5+
Simplify example wrangler.toml, and fix outdated README

packages/adapter-cloudflare-workers/README.md

+19-39
Original file line numberDiff line numberDiff line change
@@ -33,62 +33,42 @@ export default {
3333

3434
## Basic Configuration
3535

36-
**You will need [Wrangler](https://developers.cloudflare.com/workers/cli-wrangler/install-update) installed on your system**
37-
38-
This adapter expects to find a [wrangler.toml](https://developers.cloudflare.com/workers/platform/sites/configuration) file in the project root. It will determine where to write static assets and the worker based on the `site.bucket` and `site.entry-point` settings.
39-
40-
Generate this file using `wrangler` from your project directory
41-
42-
```sh
43-
wrangler init --site my-site-name
44-
```
45-
46-
Now you should get some details from Cloudflare. You should get your:
47-
48-
1. Account ID
49-
2. And your Zone-ID (Optional)
50-
51-
Get them by visiting your [Cloudflare dashboard](https://dash.cloudflare.com) and click on any domain. There, you can scroll down and on the left, you can see your details under **API**.
52-
53-
Then configure your sites build directory and your account-details in the config file:
36+
This adapter expects to find a [wrangler.toml](https://developers.cloudflare.com/workers/platform/sites/configuration) file in the project root. It should look something like this:
5437

5538
```toml
56-
account_id = 'YOUR ACCOUNT_ID'
57-
zone_id = 'YOUR ZONE_ID' # optional, if you don't specify this a workers.dev subdomain will be used.
39+
name = "<your-service-name>"
40+
account_id = "<your-account-id>"
41+
42+
main = "./.cloudflare/worker.js"
43+
site.bucket = "./.cloudflare/public"
5844

59-
type = "javascript"
45+
build.command = "npm run build"
6046

61-
[build]
62-
# Assume it's already been built. You can make this "npm run build" to ensure a build before publishing
63-
command = ""
47+
compatibility_date = "2021-11-12"
48+
workers_dev = true
49+
```
6450

65-
[build.upload]
66-
format = "modules"
67-
main = "./worker.mjs"
51+
`<your-service-name>` can be anything. `<your-account-id>` can be found by logging into your [Cloudflare dashboard](https://dash.cloudflare.com) and grabbing it from the end of the URL:
6852

69-
[site]
70-
bucket = "./.cloudflare/assets"
71-
entry-point = "./.cloudflare/worker"
53+
```
54+
https://dash.cloudflare.com/<your-account-id>
7255
```
7356

74-
It's recommended that you add the `build` and `workers-site` folders (or whichever other folders you specify) to your `.gitignore`.
57+
> It's recommended that you add the `.cloudflare` directory (or whichever directories you specified for `main` and `site.bucket`) to your `.gitignore`.
7558
76-
Now, log in with wrangler:
59+
You will need to install [wrangler](https://developers.cloudflare.com/workers/wrangler/get-started/) and log in, if you haven't already:
7760

78-
```sh
61+
```
62+
npm i -g wrangler
7963
wrangler login
8064
```
8165

82-
Build your project and publish it:
66+
Then, you can build your app and deploy it:
8367

8468
```sh
85-
npm run build && wrangler publish
69+
wrangler publish
8670
```
8771

88-
**You are done!**
89-
90-
More info on configuring a cloudflare worker site can be found [here](https://developers.cloudflare.com/workers/platform/sites/start-from-existing)
91-
9272
## Changelog
9373

9474
[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/master/packages/adapter-cloudflare-workers/CHANGELOG.md).

packages/adapter-cloudflare-workers/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ function validate_config(builder) {
116116
117117
name = "<your-site-name>"
118118
account_id = "<your-account-id>"
119-
route = "<your-route>"
120119
121120
main = "./.cloudflare/worker.js"
122121
site.bucket = "./.cloudflare/public"

0 commit comments

Comments
 (0)