Skip to content

Commit 906c110

Browse files
committed
error if site key is in wrangler config
1 parent 2b08bd3 commit 906c110

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

documentation/docs/25-build-and-deploy/60-adapter-cloudflare.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ declare global {
9797
export {};
9898
```
9999

100-
### Testing Locally
100+
### Testing locally
101101

102102
Cloudflare Workers specific values in the `platform` property are emulated during dev and preview modes. Local [bindings](https://developers.cloudflare.com/pages/functions/bindings/) are created based on your [Wrangler configuration file](https://developers.cloudflare.com/pages/functions/wrangler-configuration/#local-development) and are used to populate `platform.env` during development and preview. Use the adapter config [`platformProxy` option](#Options-platformProxy) to change your preferences for the bindings.
103103

@@ -121,7 +121,7 @@ You may wish to refer to [Cloudflare's documentation for deploying a SvelteKit s
121121

122122
If you would like to enable [Node.js compatibility](https://developers.cloudflare.com/workers/runtime-apis/nodejs/), you can add the `nodejs_compat` compatibility flag to your Wrangler configuration file:
123123

124-
```json
124+
```jsonc
125125
/// file: wrangler.jsonc
126126
{
127127
"compatibility_flags": ["nodejs_compat"]

documentation/docs/25-build-and-deploy/70-adapter-cloudflare-workers.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ Path to your [Wrangler configuration file](https://developers.cloudflare.com/wor
3838

3939
Preferences for the emulated `platform.env` local bindings. See the [getPlatformProxy](https://developers.cloudflare.com/workers/wrangler/api/#parameters-1) Wrangler API documentation for a full list of options.
4040

41-
## Basic Configuration
41+
## Basic configuration
4242

4343
This adapter expects to find a [Wrangler configuration file](https://developers.cloudflare.com/workers/configuration/sites/configuration/) in the project root. It should look something like this:
4444

45-
```json
45+
```jsonc
4646
/// file: wrangler.jsonc
4747
{
4848
"name": "<your-service-name>",
@@ -92,7 +92,7 @@ declare global {
9292
export {};
9393
```
9494

95-
### Testing Locally
95+
### Testing locally
9696

9797
Cloudflare Workers specific values in the `platform` property are emulated during dev and preview modes. Local [bindings](https://developers.cloudflare.com/workers/wrangler/configuration/#bindings) are created based on your [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/) and are used to populate `platform.env` during development and preview. Use the adapter config [`platformProxy` option](#Options-platformProxy) to change your preferences for the bindings.
9898

@@ -108,7 +108,7 @@ The [`_headers`](https://developers.cloudflare.com/pages/configuration/headers/)
108108

109109
If you would like to enable [Node.js compatibility](https://developers.cloudflare.com/workers/runtime-apis/nodejs/), you can add the `nodejs_compat` compatibility flag to your Wrangler configuration file:
110110

111-
```json
111+
```jsonc
112112
/// file: wrangler.jsonc
113113
{
114114
"compatibility_flags": ["nodejs_compat"]
@@ -127,14 +127,18 @@ You can't use `fs` in Cloudflare Workers — you must [prerender](page-options#p
127127

128128
Cloudflare no longer recommends using [Workers Sites](https://developers.cloudflare.com/workers/configuration/sites/configuration/) and instead recommends using [Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/). To migrate, remove all `site` configuration settings from your Wrangler configuration file and add the `assets.directory` and `assets.binding` configuration settings:
129129

130+
### wrangler.toml
131+
130132
```toml
131133
/// file: wrangler.toml
132134
---site.bucket = ".cloudflare/public"---
133135
+++assets.directory = ".cloudflare/public"
134136
assets.binding = "ASSETS"+++
135137
```
136138

137-
```json
139+
### wrangler.jsonc
140+
141+
```jsonc
138142
/// file: wrangler.jsonc
139143
{
140144
--- "site": {

packages/adapter-cloudflare-workers/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ Sample wrangler.jsonc:
150150
);
151151
}
152152

153+
if (wrangler_config.site) {
154+
throw new Error(
155+
`You must remove all \`site\` keys in ${wrangler_config.configPath}. Consult https://svelte.dev/docs/kit/adapter-cloudflare-workers#Migrating-from-Workers-Sites-to-Workers-Static-Assets`
156+
);
157+
}
158+
153159
if (!wrangler_config.assets?.directory) {
154160
throw new Error(
155161
`You must specify the \`assets.directory\` key in ${wrangler_config.configPath}. Consult https://developers.cloudflare.com/workers/static-assets/binding/`

0 commit comments

Comments
 (0)