Skip to content
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# Prevents Windows clones (with core.autocrlf=true) from converting LF→CRLF
# and breaking oxfmt, which only accepts LF.
* text=auto eol=lf
apps/web/worker-configuration.d.ts whitespace=-trailing-space
28 changes: 19 additions & 9 deletions .github/workflows/deploy-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: web
project: vinext-web
working_directory: apps/web
wrangler_config: dist/server/wrangler.json
wrangler_config: wrangler.jsonc
warm_cdn_cache: true
warm_cdn_target: https://vinext.dev
steps:
Expand Down Expand Up @@ -103,12 +103,11 @@ jobs:

- name: Apply D1 migrations (web only)
if: matrix.example.name == 'web' && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: apps/web
command: d1 migrations apply vinext-metrics --remote
working-directory: apps/web
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: vp run db:migrate:remote

- name: Deploy to Cloudflare Workers (Production)
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.example.warm_cdn_cache != true
Expand All @@ -127,21 +126,32 @@ jobs:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
WARM_CDN_TARGET: ${{ matrix.example.warm_cdn_target }}
run: |
args=(--skip-build --config "${{ matrix.example.wrangler_config }}" --experimental-warm-cdn-cache)
args=(--skip-build --experimental-warm-cdn-cache)
if [[ ! -f cloudflare.config.ts ]]; then
args+=(--config "${{ matrix.example.wrangler_config }}")
fi
if [[ -n "$WARM_CDN_TARGET" ]]; then
args+=(--warm-cdn-target "$WARM_CDN_TARGET")
fi
vp exec vinext-cloudflare deploy "${args[@]}"

- name: Deploy Preview Version
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && hashFiles(format('{0}/cloudflare.config.ts', matrix.example.working_directory)) == ''
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: ${{ matrix.example.working_directory }}
command: versions upload --config ${{ matrix.example.wrangler_config }} --preview-alias pr-${{ github.event.pull_request.number }}

- name: Deploy Build Output Preview Version with cf
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && hashFiles(format('{0}/cloudflare.config.ts', matrix.example.working_directory)) != ''
working-directory: ${{ matrix.example.working_directory }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: vp exec cf versions upload --prebuilt --preview-alias pr-${{ github.event.pull_request.number }}

# `versions upload` does not apply non-versioned workers.dev/preview URL
# settings. A newly added assets-only Worker has no routes until this runs.
- name: Apply Static Export Preview Routes
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ out/
.ecosystem-test/
.next/
.wrangler/
.cloudflare/
test-results/
playwright-report/
out-e2e
Expand Down
48 changes: 48 additions & 0 deletions apps/web/cloudflare.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
bindings,
defineSettings,
defineWorker,
exports as workerExports,
triggers,
} from "@cloudflare/vite-plugin/experimental-config";

export const settings = defineSettings({
accountId: "d48e2eb599d9aa075d5e682deaecc518",
});

export default defineWorker({
name: "vinext-web",
entrypoint: "./worker/index.ts",
compatibilityDate: "2026-04-08",
compatibilityFlags: ["nodejs_compat"],
previewUrls: true,
assets: { notFoundHandling: "none" },
env: {
ASSETS: bindings.assets(),
IMAGES: bindings.images(),
DB: bindings.d1({
id: "63e7cd24-9d47-4f17-a41d-b5806babc406",
name: "vinext-metrics",
}),
VINEXT_KV_CACHE: bindings.kv({
id: "08075d24ec854a19a52c13f031723def",
}),
PERFORMANCE_PROFILES: bindings.r2({
name: "vinext-performance-profiles",
}),
COMPAT_INGEST_SECRET: bindings.secret(),
CF_VERSION_METADATA: bindings.versionMetadata(),
},
triggers: [triggers.scheduled({ schedule: "17 * * * *" })],
cache: { enabled: false },
exports: {
VinextCachedResponse: workerExports.worker({ cache: { enabled: true } }),
VinextUncachedResponse: workerExports.worker({ cache: { enabled: false } }),
},
observability: {
enabled: true,
headSamplingRate: 1,
logs: { enabled: true, invocationLogs: true },
traces: { enabled: true },
},
});
23 changes: 10 additions & 13 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,39 @@
"private": true,
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"dev:vinext": "vinext dev --port 3001",
"build:vinext": "vinext build",
"start:vinext": "vinext start",
"dev": "cf dev",
"build": "cf build",
"start": "vinext start",
"deploy:cloudflare": "vinext-cloudflare deploy --experimental-warm-cdn-cache --warm-cdn-target https://vinext.dev",
"db:generate": "drizzle-kit generate",
"db:migrate:local": "wrangler d1 migrations apply vinext-metrics --local",
"db:migrate:remote": "wrangler d1 migrations apply vinext-metrics --remote"
"db:migrate:local": "cf d1 migrations apply 63e7cd24-9d47-4f17-a41d-b5806babc406 --local",
"db:migrate:remote": "cf d1 migrations apply 63e7cd24-9d47-4f17-a41d-b5806babc406"
},
"dependencies": {
"@cloudflare/kumo": "catalog:",
"@phosphor-icons/react": "catalog:",
"@vinext/cloudflare": "workspace:*",
"drizzle-orm": "catalog:",
"next": "catalog:",
"react": "catalog:",
"react-dom": "catalog:",
"shiki": "catalog:",
"vinext": "workspace:*"
},
"devDependencies": {
"@cloudflare/vite-plugin": "catalog:",
"@cloudflare/workers-types": "catalog:",
"@cloudflare/vite-plugin": "https://pkg.pr.new/@cloudflare/vite-plugin@15508",
"@tailwindcss/postcss": "catalog:",
"@types/node": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"@vitejs/plugin-react": "catalog:",
"@vitejs/plugin-rsc": "catalog:",
"cf": "catalog:cloudflare-vite-v2",
"drizzle-kit": "catalog:",
"postcss": "catalog:",
"react-server-dom-webpack": "catalog:",
"tailwindcss": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
"wrangler": "catalog:"
"vite": "catalog:cloudflare-vite-v2",
"wrangler": "catalog:cloudflare-vite-v2"
}
}
6 changes: 0 additions & 6 deletions apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"types": ["@cloudflare/workers-types"],
"paths": {
"@/*": ["./*"]
}
Expand Down
Loading
Loading