본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)5.4k · #14846

cloudflare-bundler-apps

하는 일

이 스킬은 Cloudflare 워커 번들러가 프로젝트를 깔끔하게 빌드할 수 있도록 구조를 짜는 방법을 에이전트에게 가르칩니다. wrangler 설정, 폴더 레이아웃, 정적 파일, 서버 진입점을 다룹니다.

사용하는 경우

  • ✓개발자가 Cloudflare 워커 번들러로 빌드될 프로젝트를 만들거나 바꿀 때.
  • ✓Cloudflare 프로젝트의 미리 보기가 빈 페이지를 보여 주거나 빌드가 실패하는 경우.
  • ✓프로젝트에 서버 진입점과 함께 정적 에셋을 제공해야 할 때.

스킬 링크

https://github.com/cloudflare/vibesdk/blob/main/worker/agents/think/skills/app-file-structure/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/cloudflare/vibesdk/blob/main/worker/agents/think/skills/app-file-structure/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“번들러가 빌드하고 미리 보기에 오류 없이 페이지가 보이도록 제 Cloudflare 프로젝트를 설정해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 wrangler 설정에서 메인 진입점, 호환성 설정, 에셋 폴더를 읽은 뒤, 번들러 규칙에 맞게 프로젝트를 배치합니다. 의존성 제한과 빈 페이지를 일으키는 흔한 실수를 확인합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

This skill teaches how to build apps that deploy cleanly through the space deploy pipeline. Every project committed to a space is built by @cloudflare/worker-bundler (createApp when there are static assets, createWorker when there are none) and served on a Dynamic Worker via WorkerLoader. Get the conventions right and the preview "just works". Get them wrong and you get a blank page, a 500, or a Build failed error.

How the pipeline works

When deploy_space(branch) is called, the space DO:

  1. Reads every file from the branch's working tree (skipping .git/).
  2. Parses wrangler.json / wrangler.jsonc / wrangler.toml for main, compatibility_date, compatibility_flags, and [assets].
  3. If [assets].directory is set, files under that directory become static assets served host-side by handleAssetRequest. Everything else is built into a Worker via createApp (with server: <main>).
  4. If no assets directory is configured, only createWorker({ entryPoint: <main> }) is run. The output is loaded as a Dynamic Worker; all requests go to the Worker.
  5. Previews are served at /space/:name/preview/:branch/*. Responses with content-type: text/html are run through HTMLRewriter, which prefixes root-relative src / href / action attributes with the preview base path. JS-side fetches and dynamic imports are NOT rewritten.

Practical consequences:

  • You can rely on root-relative src="/foo.js" and href="/style.css" in HTML. They will be rewritten to the preview path automatically.
  • You cannot rely on root-relative paths inside JS strings: fetch("/api/x"), new URL("/foo", location.origin), dynamic import("/lib.js"). These hit the wrong path under the preview prefix. Use relative paths (./api/x, import.meta.url) or read the base path from <base href> / a meta tag injected at build time.
  • The <base href> tag is also rewritten if present — using it lets all relative URLs resolve against the preview path.

Project layout

A typical full-stack space project:

/
├── wrangler.json          # required for non-trivial setups
├── package.json           # npm deps (text-only packages, see limits below)
├── src/
│   └── index.ts           # server entry: export default { fetch }
└── public/                # static assets directory (configurable)
    ├── index.html
    ├── app.js             # compiled, no JSX
    └── styles.css

A static-only SPA can skip src/ entirely — just wrangler.json + public/ is enough as long as main points to a minimal pass-through worker or you accept that all requests fall through assets.

Wrangler config

Minimum viable wrangler.json:

{
  "main": "src/index.ts",
  "compatibility_date": "2025-04-01",
  "assets": {
    "directory": "./public",
    "html_handling": "auto-trailing-slash",
    "not_found_handling": "single-page-application"
  }
}

Notes:

  • main is required when there's any server code. The bundler also auto-detects src/index.ts, src/index.js, index.ts, index.js if missing.
  • compatibility_date defaults to 2025-04-01 if omitted. Set it explicitly for newer features.
  • Add "compatibility_flags": ["nodejs_compat"] only if you actually need Node built-ins.
  • assets.directory is the only way to ship static files. Files outside this directory are bundled into the Worker or ignored — they will not be reachable via URL.
  • html_handling: "auto-trailing-slash" is usually what you want for multi-page sites; SPAs should also set not_found_handling: "single-page-application" so deep links return index.html.

TOML works too (wrangler.toml), but the parser only handles top-level scalar fields plus an [assets] table — no inline tables, no env overrides. Prefer JSON.

Server entry: one Durable Object class named App

Your entire backend is one Durable Object. Your main module exports a class named App extending DurableObject. The platform loads it as a Cloudflare Durable Object Facet of the host SpaceDO and forwards every non-asset request — including WebSocket upgrades — to your App.fetch(request).

Do not export default { fetch }. A default fetch handler will be ignored. There is no separate worker; the DO is the worker.

// src/index.ts
import { DurableObject } from "cloudflare:workers";

export class App extends DurableObject {
  async fetch(request: Request): Promi
자주 묻는 질문

빈 미리 보기의 원인은 무엇인가요?

스킬은 빈 페이지나 빌드 실패로 이어지는 설정 및 레이아웃 실수를 나열합니다.

브라우저 요청이 다시 쓰이나요?

스킬은 HTML 속성은 미리 보기 경로에 맞게 다시 쓰이지만, JavaScript의 fetch 호출과 import는 그렇지 않다고 설명합니다.

어떤 설정 파일을 읽나요?

wrangler.json, wrangler.jsonc, wrangler.toml을 읽습니다.

상세 정보

작성자의 원본 설명

Author Cloudflare Worker Bundler-compatible apps that build and preview correctly inside a space. Use this skill whenever you scaffold, modify, or deploy a project that will be built with `@cloudflare/worker-bundler` (i.e. anything served from `/space/:name/preview/:branch/`). Covers wrangler config, project layout, static asset rules, server entry conventions, npm dependency limits, and the most common cause of blank previews (JSX in browser scripts).

repo: cloudflare/vibesdk

인기도

GitHub 스타
5.4k
순위
#14846
라이선스
MIT
업데이트
2026. 10. 21.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬