Skip to content

Custom output folders and leaf.toml

While LeafCloud automatically detects common frontend frameworks, you can override detection and customize build behaviors using leaf.toml or CLI flags.

Place a leaf.toml file in the root directory of your project:

# Target site on LeafCloud
site = "my-cool-project"
# Custom directory containing the static output
dir = "dist"
# Custom build command to run before deployment
build = "npm run build:prod"
# Custom 404 error page path relative to the output directory
not_found = "404.html"
KeyTypeDescription
sitestringThe name of the target site on LeafCloud.
dirstringRelative or absolute path to the directory containing pre-built assets.
buildstringCommand executed by leaf deploy before hashing and uploading.
not_foundstringPath to the custom 404 page served when a requested URL is not found.

Command-line flags take precedence over settings in leaf.toml:

You can specify the output directory at deploy time using --dir or a positional path:

Terminal window
# Using the --dir flag
leaf deploy --dir public
# Or using a positional path
leaf deploy build/client

Note: Specifying both a positional path and --dir will result in an error: Use either a positional directory or --dir, not both.

If leaf.toml defines a build command (or your framework was auto-detected) but you want to deploy the existing output folder without re-running the build, use --no-build:

Terminal window
leaf deploy --no-build

For single-page applications that use client-side routing, route fallback traffic by pointing not_found to your index.html:

leaf.toml
site = "spa-app"
dir = "dist"
not_found = "index.html"