@sveltejs/adapter-cloudflare-workers
Advanced tools
Comparing version 1.0.0-next.23 to 1.0.0-next.24
{ | ||
"name": "@sveltejs/adapter-cloudflare-workers", | ||
"version": "1.0.0-next.23", | ||
"version": "1.0.0-next.24", | ||
"repository": { | ||
@@ -25,6 +25,6 @@ "type": "git", | ||
"@iarna/toml": "^2.2.5", | ||
"esbuild": "^0.13.3" | ||
"esbuild": "^0.13.4" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/kit": "1.0.0-next.177" | ||
"@sveltejs/kit": "1.0.0-next.181" | ||
}, | ||
@@ -31,0 +31,0 @@ "scripts": { |
@@ -9,2 +9,4 @@ # adapter-cloudflare-workers | ||
**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 will determine where to write static assets and the worker based on the `site.bucket` and `site.entry-point` settings. | ||
@@ -15,11 +17,30 @@ | ||
```sh | ||
$ wrangler init --site my-site-name | ||
wrangler init --site my-site-name | ||
``` | ||
Then configure your sites build directory in the config file: | ||
Add the adapter to your `svelte.config.js`: | ||
```js | ||
import adapter from '@sveltejs/adapter-cloudflare-workers'; | ||
export default { | ||
kit: { | ||
target: '#svelte', | ||
adapter: adapter() | ||
} | ||
}; | ||
``` | ||
Now you should get some details from Cloudflare. You should get your: | ||
1. Account ID | ||
2. And your Zone-ID (Optional) | ||
Get them by visiting your Cloudflare-Dashboard and click on any domain. There, you can scroll down and on the left, you can see your details under **API**. | ||
Then configure your sites build directory and your account-details in the config file: | ||
```toml | ||
[site] | ||
bucket = "./build" | ||
entry-point = "./workers-site" | ||
account_id = 'YOUR ACCOUNT_ID' | ||
zone_id = 'YOUR ZONE_ID' # optional, if you don't specify this a workers.dev subdomain will be used. | ||
site = {bucket = "./build", entry-point = "./workers-site"} | ||
``` | ||
@@ -29,2 +50,16 @@ | ||
Now, log in with wrangler: | ||
```sh | ||
wrangler login | ||
``` | ||
Build your project and publish it: | ||
```sh | ||
npm run build && 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) | ||
@@ -42,5 +77,5 @@ | ||
adapterCfw({ | ||
esbuild(defaultOptions) { | ||
esbuild(options) { | ||
return { | ||
...defaultOptions, | ||
...options, | ||
plugins: [] | ||
@@ -55,9 +90,9 @@ }; | ||
```js | ||
{ | ||
entryPoints: ['.svelte-kit/cloudflare-workers/entry.js'], | ||
outfile: `${entrypoint}/index.js`, | ||
bundle: true, | ||
target: 'es2020', | ||
platform: 'browser' | ||
} | ||
const options = { | ||
entryPoints: ['.svelte-kit/cloudflare-workers/entry.js'], | ||
outfile: `${entrypoint}/index.js`, | ||
bundle: true, | ||
target: 'es2020', | ||
platform: 'browser' | ||
}; | ||
``` | ||
@@ -64,0 +99,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9984
98
Updatedesbuild@^0.13.4