跳转到内容
本站为社区维护的非官方中文翻译,与 Cloudflare, Inc. 无关联。本站不提供账户登录,请勿在任何非官方站点输入您的 Cloudflare 账户信息。官方文档:developers.cloudflare.com

配置浏览器

最后更新 查看 MarkdownAgent 设置

cloudflare.config.ts 是 TypeScript 文件,因此每个字段都有类型和说明。使用配置浏览器查看此文件如何描述应用的主要部分:项目设置、Worker、绑定、触发器和导出项。

选择一个类别,再选择高亮显示的字段,即可查看其类型、说明、默认值和可接受的选项。支持 TypeScript 的编辑器会在你编写文件时,通过自动补全和悬停提示显示相同信息;类型检查会标记不匹配的值。

要了解如何组织项目配置,请参阅以编程方式配置。要为每个环境返回不同的配置,请参阅模式。

Select a highlighted line to show its type and description below it.

Generated from @cloudflare/config0.20.0

defineConfig

import { defineConfig } from "cf/config";
import * as entrypoint from "./src/index" with { type: "cf-worker" };
export default defineConfig(({ isPreview, mode }) => ({ (isPreview, mode reference)

isPreviewContext valueLink to isPreview

isPreview: boolean

Whether the config is being evaluated for a Preview build.

modeContext valueLink to mode

mode: string | undefined

The mode the config is being evaluated in. Set via the --mode CLI flag. In Vite the mode defaults to development in vite dev and production in vite build (more info). In Wrangler the mode defaults to undefined.

accountId: "<ACCOUNT_ID>", (accountId reference)

accountIdOptionalLink to accountId

accountId?: string

This is the ID of the account associated with your zone. It can also be specified through the CLOUDFLARE_ACCOUNT_ID environment variable.

complianceRegion: mode === "fedramp" ? "fedramp-high" : "public", (complianceRegion reference)

complianceRegionOptionalLink to complianceRegion

complianceRegion?: "public" | "fedramp-high"

The compliance boundary in which commands should operate. When omitted, this can be supplied through CLOUDFLARE_COMPLIANCE_REGION.

worker: { (worker reference)

workerOptionalLink to worker

worker?: ConfigInput<WorkerConfig>

The Worker defined by this configuration.

name: isPreview ? "example-preview" : "example-worker", (name reference)

nameRequiredLink to name

name: string

The name of your Worker.

entrypoint, (entrypoint reference)

entrypointOptionalLink to entrypoint

entrypoint?: string | WorkerModule

The entrypoint module that will be executed. May be either a path string (e.g. "./src/index.ts") or a module namespace imported with the cf-worker import attribute.

compatibilityDate: "<COMPATIBILITY_DATE>", (compatibilityDate reference)

compatibilityDateRequiredLink to compatibilityDate

compatibilityDate: string

A date in the form yyyy-mm-dd, which will be used to determine which version of the Workers runtime is used. More details at https://developers.cloudflare.com/workers/configuration/compatibility-dates

},
containers: [], (containers reference)

containersOptionalLink to containers

containers?: ConfigInput<ContainerConfig>[]

Container applications defined by this configuration.

}));

这篇文档对您有帮助吗?