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.
The leaf.toml configuration file
Section titled “The leaf.toml configuration file”Place a leaf.toml file in the root directory of your project:
# Target site on LeafCloudsite = "my-cool-project"
# Custom directory containing the static outputdir = "dist"
# Custom build command to run before deploymentbuild = "npm run build:prod"
# Custom 404 error page path relative to the output directorynot_found = "404.html"Supported configuration keys
Section titled “Supported configuration keys”| Key | Type | Description |
|---|---|---|
site | string | The name of the target site on LeafCloud. |
dir | string | Relative or absolute path to the directory containing pre-built assets. |
build | string | Command executed by leaf deploy before hashing and uploading. |
not_found | string | Path to the custom 404 page served when a requested URL is not found. |
CLI overrides
Section titled “CLI overrides”Command-line flags take precedence over settings in leaf.toml:
Override output directory
Section titled “Override output directory”You can specify the output directory at deploy time using --dir or a positional path:
# Using the --dir flagleaf deploy --dir public
# Or using a positional pathleaf deploy build/clientNote: Specifying both a positional path and
--dirwill result in an error:Use either a positional directory or --dir, not both.
Skip the build command
Section titled “Skip the build command”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:
leaf deploy --no-buildStatic single-page applications (SPAs)
Section titled “Static single-page applications (SPAs)”For single-page applications that use client-side routing, route fallback traffic by pointing not_found to your index.html:
site = "spa-app"dir = "dist"not_found = "index.html"