Skip to content

Commit 05ffe66

Browse files
committed
refactor(www): migrate from Workers to Cloudflare Pages for static deployment
1 parent 92e8131 commit 05ffe66

File tree

9 files changed

+883
-35
lines changed

9 files changed

+883
-35
lines changed

.github/workflows/deploy-www.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ permissions:
1818
jobs:
1919
deploy:
2020
runs-on: ubuntu-latest
21-
name: Publish www (Nuxt SSR) to Cloudflare Workers
21+
name: Publish www to Cloudflare Pages
2222
concurrency:
2323
group: deploy-www-${{ github.ref }}
2424
cancel-in-progress: true
@@ -38,10 +38,9 @@ jobs:
3838
NODE_OPTIONS: --max-old-space-size=6144
3939
run: pnpm build:www
4040

41-
- name: Publish to Cloudflare Workers via Wrangler
42-
working-directory: apps/www
41+
- name: Publish to Cloudflare Pages via Wrangler
4342
env:
4443
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
4544
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
4645
run: |
47-
npx wrangler@4 deploy --config wrangler.toml
46+
pnpm --filter www deploy

apps/www/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@ pnpm dev
2121

2222
## Production
2323

24-
Build the application for production:
24+
Build a fully static version of the docs (outputs to `.output/public`):
2525

2626
```bash
2727
pnpm build
2828
```
2929

30-
Locally preview production build:
30+
Preview the generated site with Cloudflare Pages tooling:
3131

3232
```bash
33+
# run after pnpm build
3334
pnpm preview
3435
```
36+
37+
Deploy to Cloudflare Pages (requires `wrangler login` once):
38+
39+
```bash
40+
# from apps/www
41+
pnpm run deploy
42+
```

apps/www/app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default defineAppConfig({
3131
target: '_self',
3232
}, {
3333
title: 'Examples',
34-
to: '/examples',
34+
to: '/examples/chatbot',
3535
description: 'Real-world examples showing how to build applications with AI Elements Vue',
3636
target: '_self',
3737
}, {

apps/www/content/3.components/1.chatbot/conversation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export { default as ConversationScrollButton } from './ConversationScrollButton.
184184

185185
## Usage with AI SDK
186186

187-
Build a simple conversational UI with `Conversation` and [`PromptInput`](/components/prompt-input):
187+
Build a simple conversational UI with `Conversation` and [`PromptInput`](/components/chatbot/prompt-input):
188188

189189
Add the following component to your frontend:
190190

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
title: Vibe Coding
22
icon: lucide:code
3-
navigation.redirect: /components/vibe-coding/
3+
navigation.redirect: /components/vibe-coding/artifact

apps/www/nuxt.config.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ export default defineNuxtConfig({
55

66
plugins: ['~/plugins/ai-elements'],
77

8+
experimental: {
9+
payloadExtraction: false,
10+
},
11+
812
mdc: {
913
highlight: {
1014
shikiEngine: 'javascript',
15+
theme: {
16+
default: 'github-light',
17+
dark: 'github-dark',
18+
},
1119
},
1220
},
1321

@@ -39,10 +47,14 @@ export default defineNuxtConfig({
3947
transpile: ['@repo/examples'],
4048
},
4149

42-
compatibilityDate: '2024-07-06',
50+
compatibilityDate: '2024-09-19',
4351

4452
sourcemap: false,
4553

54+
routeRules: {
55+
'/**': { prerender: true },
56+
},
57+
4658
vite: {
4759
build: {
4860
sourcemap: false,
@@ -64,12 +76,24 @@ export default defineNuxtConfig({
6476
},
6577

6678
nitro: {
67-
preset: 'cloudflare-module',
68-
},
69-
70-
alias: {
71-
// Replace Playwright with a mock to bypass Cloudflare build restrictions.
72-
'playwright-core': 'unenv/mock/proxy',
73-
'playwright': 'unenv/mock/proxy',
79+
preset: 'cloudflare_pages',
80+
cloudflare: {
81+
deployConfig: false,
82+
nodeCompat: true,
83+
pages: {
84+
routes: {
85+
include: ['/*'],
86+
exclude: ['/api/_mdc/*'],
87+
},
88+
},
89+
},
90+
prerender: {
91+
crawlLinks: true,
92+
autoSubfolderIndex: false,
93+
failOnError: true,
94+
},
95+
storage: {
96+
cache: { driver: 'memory' },
97+
},
7498
},
7599
})

apps/www/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
"version": "0.14.2",
55
"private": true,
66
"scripts": {
7-
"build": "nuxt build",
7+
"build": "nuxt generate",
88
"dev": "nuxt dev --port 3002",
99
"generate": "nuxt generate",
10-
"preview": "nuxt preview",
10+
"preview": "wrangler pages dev",
11+
"deploy": "wrangler pages deploy --project-name ai-elements-vue",
1112
"postinstall": "nuxt prepare"
1213
},
1314
"dependencies": {
1415
"@repo/elements": "workspace:*",
1516
"@repo/examples": "workspace:*",
17+
"@vueuse/shared": "^14.1.0",
1618
"highlight.js": "^11.11.1",
1719
"nuxt": "3.18.0",
1820
"shadcn-docs-nuxt": "^1.1.4",
@@ -24,6 +26,8 @@
2426
"@iconify-json/logos": "^1.2.9",
2527
"@iconify-json/lucide": "^1.2.73",
2628
"@iconify-json/simple-icons": "^1.2.54",
27-
"tailwindcss-animate": "^1.0.7"
29+
"baseline-browser-mapping": "^2.9.2",
30+
"tailwindcss-animate": "^1.0.7",
31+
"wrangler": "^4.52.1"
2832
}
2933
}

apps/www/wrangler.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
name = "ai-elements-vue"
2-
main = ".output/server/index.mjs"
3-
compatibility_date = "2024-07-06"
4-
compatibility_flags = [ "nodejs_compat" ]
5-
routes = [ "www.ai-elements-vue.com/*" ]
6-
site = { bucket = ".output/public" }
2+
compatibility_date = "2024-09-19"
3+
pages_build_output_dir = "dist"

0 commit comments

Comments
 (0)