Skip to content

Commit

Permalink
align README with the error message printed when wrangler.toml is mis…
Browse files Browse the repository at this point in the history
…sing
  • Loading branch information
Rich-Harris committed Jun 21, 2022
1 parent e390f55 commit cf10007
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 37 deletions.
55 changes: 19 additions & 36 deletions packages/adapter-cloudflare-workers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,59 +33,42 @@ export default {

## Basic Configuration

**You will need [Wrangler](https://developers.cloudflare.com/workers/cli-wrangler/install-update) installed on your system**
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:

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.

Generate this file using `wrangler` from your project directory

```sh
wrangler init --site my-site-name
```

Now you should get some details from Cloudflare. You should get your Account ID.

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**.
```toml
name = "<your-service-name>"
account_id = "<your-account-id>"

Then configure your sites build directory and your account-details in the
config file:
main = "./.cloudflare/worker.js"
site.bucket = "./.cloudflare/public"

```toml
main = "./worker.mjs"
account_id = 'YOUR ACCOUNT_ID'
build.command = "npm run build"

# A compatibility_date is required when publishing. Add one to your
# wrangler.toml file, or pass it in your terminal as --compatibility-date
compatibility_date = '2022-06-09'
compatibility_date = "2021-11-12"
workers_dev = true
```

[build]
# Assume it's already been built. You can make this "npm run build" to ensure a
# build before publishing
command = ""
`<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:

[site]
bucket = "./.cloudflare/assets"
```
https://dash.cloudflare.com/<your-account-id>
```

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

```sh
```
npm i -g wrangler
wrangler login
```

Build your project and publish it:
Then, you can build your app and deploy it:

```sh
npm run build && wrangler publish
wrangler publish
```

**You are done!**

More info on configuring a cloudflare worker site can be found [here](https://developers.cloudflare.com/workers/platform/sites/start-from-existing)

## Changelog

[The Changelog for this package is available on GitHub](https://github.com/sveltejs/kit/blob/master/packages/adapter-cloudflare-workers/CHANGELOG.md).
1 change: 0 additions & 1 deletion packages/adapter-cloudflare-workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ function validate_config(builder) {
name = "<your-site-name>"
account_id = "<your-account-id>"
route = "<your-route>"
main = "./.cloudflare/worker.js"
site.bucket = "./.cloudflare/public"
Expand Down

0 comments on commit cf10007

Please sign in to comment.