API
The cloudflare plugin should be included in the Vite plugins array:
import { defineConfig } from "vite";import { cloudflare } from "@cloudflare/vite-plugin";
export default defineConfig({ plugins: [cloudflare()],});It accepts an optional PluginConfig parameter.
-
configPathstring optionalAn optional path to your Worker config file. By default, a
wrangler.jsonc,wrangler.json, orwrangler.tomlfile in the root of your application will be used as the Worker config.For more information about the Worker configuration, see Configuration.
-
configPartial<WorkerConfig> | ((config: WorkerConfig) => Partial<WorkerConfig> | void) optionalCustomize or override Worker configuration programmatically. Accepts a partial configuration object or a function that receives the current config.
Applied after any config file loads. Use it to override values, modify the existing config, or define Workers entirely in code.
See Programmatic configuration for details.
-
viteEnvironment{ name?: string } optionalOptional Vite environment options. By default, the environment name is the Worker name with
-characters replaced with_. Setting the name here will override this. A typical use case is settingviteEnvironment: { name: "ssr" }to apply the Worker to the SSR environment.See Vite Environments for more information.
-
persistStateboolean | { path: string } optionalAn optional override for state persistence. By default, state is persisted to
.wrangler/state. A custompathcan be provided or, alternatively, persistence can be disabled by setting the value tofalse. -
inspectorPortnumber | false optionalAn optional override for debugging your Workers. By default, the debugging inspector is enabled and listens on port
9229. A custom port can be provided or, alternatively, setting this tofalsewill disable the debugging inspector.See Debugging for more information.
-
auxiliaryWorkersArray<AuxiliaryWorkerConfig> optionalAn optional array of auxiliary Workers. Auxiliary Workers are additional Workers that are used as part of your application. You can use service bindings to call auxiliary Workers from your main (entry) Worker. All requests are routed through your entry Worker. During the build, each Worker is output to a separate subdirectory of
dist.
Auxiliary Workers require a configPath, a config option, or both.
-
configPathstring optionalThe path to your Worker config file. This field is required unless
configis provided.For more information about the Worker configuration, see Configuration.
-
configPartial<WorkerConfig> | ((config: WorkerConfig) => Partial<WorkerConfig> | void) optionalCustomize or override Worker configuration programmatically. When used without
configPath, this allows defining auxiliary Workers entirely in code.See Programmatic configuration for usage examples.
-
viteEnvironment{ name?: string } optionalOptional Vite environment options. By default, the environment name is the Worker name with
-characters replaced with_. Setting the name here will override this.See Vite Environments for more information.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark
-