Skip to content

Commit 4c72d55

Browse files
Merge pull request #905 from IgorKowalczyk/cloudflare
Migrate from Deno Deploy to Cloudflare Workers
2 parents d135d8a + 6be6740 commit 4c72d55

12 files changed

Lines changed: 506 additions & 132 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,8 @@ dist
107107
.vercel
108108

109109
# Astro build output
110-
.astro
110+
.astro
111+
112+
# Cloudflare wrangler
113+
worker-configuration.d.ts
114+
.wrangler

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
44
"editor.codeActionsOnSave": {
55
"source.fixAll.eslint": "explicit"
6-
},
7-
"deno.enable": true
6+
}
87
}

astro.config.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
11
// https://astro.build/config
2+
import { writeFile } from "fs/promises";
3+
import { EOL } from "os";
4+
import { fileURLToPath } from "url";
5+
import cloudflare from "@astrojs/cloudflare";
26
import vue from "@astrojs/vue";
3-
import deno from "@deno/astro-adapter";
47
import tailwindcss from "@tailwindcss/vite";
58
import { defineConfig } from "astro/config";
69
import compress from "astro-compressor";
710

811
// https://astro.build/config
912
export default defineConfig({
1013
site: "https://views.igorkowalczyk.dev",
14+
1115
redirects: {
1216
"/github": "https://github.com/igorkowalczyk/views",
1317
"/docs": "https://github.com/IgorKowalczyk/github-views?tab=readme-ov-file#-basic-usage",
1418
},
15-
output: "server",
16-
adapter: deno(),
17-
integrations: [vue(), compress()],
19+
20+
integrations: [
21+
vue(),
22+
compress(),
23+
{
24+
hooks: {
25+
"astro:build:done": async ({ dir }) => {
26+
const outFile = fileURLToPath(new URL(".assetsignore", dir));
27+
await writeFile(outFile, ["_worker.js", "_routes.json", "_headers", "_redirects"].join(EOL) + EOL);
28+
},
29+
},
30+
name: "Create .assetsignore",
31+
},
32+
],
33+
1834
vite: {
1935
plugins: [tailwindcss()],
2036
},
37+
38+
output: "server",
39+
adapter: cloudflare({
40+
platformProxy: {
41+
enabled: true,
42+
configPath: "./wrangler.jsonc",
43+
},
44+
}),
2145
});

deno.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

package.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"scripts": {
77
"dev": "astro dev",
88
"build": "astro build",
9-
"preview": "deno run --allow-net --allow-read --allow-env --unstable-bare-node-builtins --unstable-kv ./dist/server/entry.mjs",
9+
"preview": "pnpm build && wrangler dev",
10+
"check": "pnpm build && tsc && wrangler deploy --dry-run",
11+
"deploy": "astro build && wrangler deploy",
12+
"types": "wrangler types",
1013
"format": "prettier . --write --ignore-unknown --cache --plugin=prettier-plugin-astro",
1114
"format:check": "prettier . --check --cache",
1215
"lint": "eslint .",
@@ -21,8 +24,6 @@
2124
"github",
2225
"profile",
2326
"astro",
24-
"deno",
25-
"deno-kv",
2627
"views-counter",
2728
"counter"
2829
],
@@ -33,18 +34,16 @@
3334
},
3435
"homepage": "https://views.igorkowalczyk.dev/",
3536
"dependencies": {
37+
"@astrojs/cloudflare": "12.3.0",
3638
"@astrojs/vue": "5.0.7",
37-
"@deno/astro-adapter": "0.3.0",
3839
"@tailwindcss/vite": "4.0.14",
39-
"@types/canvas-confetti": "1.9.0",
4040
"@vueuse/core": "13.0.0",
4141
"astro": "5.5.3",
4242
"astro-compressor": "1.0.0",
4343
"badgen": "3.2.3",
4444
"canvas-confetti": "1.9.3",
4545
"class-variance-authority": "0.7.1",
4646
"clsx": "2.1.1",
47-
"eslint-plugin-vue": "10.0.0",
4847
"lucide-vue-next": "0.483.0",
4948
"tailwind-merge": "3.0.2",
5049
"tailwindcss": "4.0.14",
@@ -54,17 +53,23 @@
5453
"@igorkowalczyk/eslint-config": "3.0.7",
5554
"@igorkowalczyk/prettier-config": "3.0.7",
5655
"@tailwindcss/forms": "0.5.10",
56+
"@types/canvas-confetti": "1.9.0",
57+
"@types/node": "22.13.11",
5758
"eslint": "9.22.0",
59+
"eslint-plugin-astro": "^1.3.1",
60+
"eslint-plugin-vue": "10.0.0",
5861
"prettier": "3.5.3",
5962
"prettier-plugin-astro": "0.14.1",
6063
"prettier-plugin-tailwindcss": "0.6.11",
61-
"typescript": "5.8.2"
64+
"typescript": "5.8.2",
65+
"wrangler": "4.3.0"
6266
},
6367
"packageManager": "pnpm@10.6.4",
6468
"pnpm": {
6569
"onlyBuiltDependencies": [
6670
"esbuild",
67-
"sharp"
71+
"sharp",
72+
"workerd"
6873
]
6974
}
7075
}

0 commit comments

Comments
 (0)