Skip to content
Cloudflare Docs

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"
}
}