Minor Changes
-
#14013
3cf9d0eThanks @jamesopstad! - Add experimentalexperimental.newConfigoption to load the entry Worker's configuration fromcloudflare.config.tsThis is an experimental, opt-in feature. When enabled, the plugin loads the entry Worker's configuration from a
cloudflare.config.tsfile instead of the usualwrangler.json/wrangler.jsonc/wrangler.toml.Pass
trueto enable with defaults, or an object to customise behaviour. Currently the only sub-option istypes.generate(defaults totrue), which writes aworker-configuration.d.tsfile next to the config. This enables typedenvandexportsfor your Worker and currently assumes that you have@cloudflare/workers-typesinstalled.// vite.config.ts import { defineConfig } from "vite"; import { cloudflare } from "@cloudflare/vite-plugin"; export default defineConfig({ plugins: [ cloudflare({ experimental: { newConfig: true, }, }), ], });
// cloudflare.config.ts import { defineWorker, bindings, } from "@cloudflare/vite-plugin/experimental-config"; import * as entrypoint from "./src/index.ts" with { type: "cf-worker" }; export default defineWorker((ctx) => ({ name: "my-worker", entrypoint, compatibilityDate: "2026-05-18", env: { MY_TEXT: bindings.text(`The mode is ${ctx.mode}`), MY_KV: bindings.kv(), }, }));
A few limitations apply while the feature is experimental:
configPathcannot be combined withexperimental.newConfig. The entry Worker is always loaded fromcloudflare.config.tsat the project root.auxiliaryWorkersare not yet supported withexperimental.newConfig.
Because this is experimental, the option, the
cloudflare.config.tsschema, and the@cloudflare/vite-plugin/experimental-configexports may change in any release.