Skip to content

Commit 9463ac4

Browse files
committed
add cloudflare workers examples
1 parent 394e364 commit 9463ac4

5 files changed

Lines changed: 5 additions & 7 deletions

File tree

File renamed without changes.
File renamed without changes.

examples/cloudflare-workers-simple/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ENV } from 'varlock/env';
1010
console.log(ENV.SOME_VAR); // works, even outside of a request
1111
```
1212

13-
> If you want to use the Vite-based Cloudflare Workers setup, see the `cloudflare-workers-vite` example instead.
13+
> If you want to use the Vite-based Cloudflare Workers setup, see the [`cloudflare-workers-vite`](../cloudflare-workers-vite) example instead.
1414
1515
## Setup
1616

examples/cloudflare-workers-simple/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This import is needed at root of worker to enable leak detection / log redaction
1+
// this is required in your main entry point if building workers without vite
22
import '@varlock/cloudflare-integration/init';
33

44
// USE THIS!
@@ -16,7 +16,7 @@ export default {
1616
console.log('Should be redacted:', ENV.SENSITIVE_ITEM);
1717

1818
return new Response(JSON.stringify({
19-
message: `Varlock example with Cloudflare workers (simple)`,
19+
message: `Varlock example with Cloudflare workers simple (no vite)`,
2020

2121
'Public item': {
2222
'ENV.ITEM1 - using varlock (recommended)': ENV.ITEM1,

examples/cloudflare-workers-vite/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This may seem strange to use Vite in a backend-only project, but Vite's environm
77
From the docs on choosing wrangler vs the vite plugin:
88
> Due to Vite's advanced configuration options and large ecosystem of plugins, there is more flexibility to customize your development experience and build output
99
10-
> For the simpler wrangler-only approach (no Vite), see the `cloudflare-workers-simple` example instead.
10+
> For the simpler wrangler-only approach (no Vite), see the [`cloudflare-workers-simple`](../cloudflare-workers-simple) example instead.
1111
1212
## Setup
1313

@@ -25,16 +25,14 @@ From the docs on choosing wrangler vs the vite plugin:
2525

2626
## How it works
2727

28-
The `vite.config.ts` uses `varlockCloudflareVitePlugin()` from `@varlock/cloudflare-integration` alongside Cloudflare's own `cloudflare()` Vite plugin. Config is resolved and injected at build time.
28+
The `vite.config.ts` uses `varlockCloudflareVitePlugin()` from `@varlock/cloudflare-integration`. This plugin wraps Cloudflare's Vite plugin internally, so you don't need to add it separately. Config is resolved and injected at build time.
2929

3030
```typescript
3131
import { varlockCloudflareVitePlugin } from "@varlock/cloudflare-integration";
32-
import { cloudflare } from "@cloudflare/vite-plugin";
3332

3433
export default defineConfig({
3534
plugins: [
3635
varlockCloudflareVitePlugin(),
37-
cloudflare(),
3836
],
3937
});
4038
```

0 commit comments

Comments
 (0)