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.
-
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.
-
configPathstringA required path to your Worker config file.
For more information about the Worker configuration, see Configuration.
-
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?
- Products
- 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