Static Assets
The Vite plugin does not require that you provide the assets
field in order to enable assets and instead determines whether assets should be included based on whether the client
environment has been built.
By default, the client
environment is built if there is an index.html
file in the root of your project or if build.rollupOptions.input
is specified in the Vite config.
On running vite build
, an output wrangler.json
configuration file is generated as part of the build output.
The assets.directory
field in this file is automatically populated with the path to your client
build output.
It is therefore not necessary to provide the assets.directory
field in your input Worker configuration.
The assets
configuration should be used, however, if you wish to set routing configuration or enable the assets binding.
The following example configures the not_found_handling
for a single-page application so that the fallback will always be the root index.html
file.
{ "assets": { "not_found_handling": "single-page-application" }}
assets = { not_found_handling = "single-page-application" }
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