Overview
Folder-based deployments use Git sparse checkout to clone only specific directories, making deployments faster and more efficient for monorepo structures.Configuration
Enable folder deployment by settingisFolder: true and specifying the folder name:
Validation Rules
From the validation schema:Database Schema
Folder settings are stored in the project model:How It Works
1
Sparse Checkout Initialization
DeployHub clones the repository with blob filtering and enables sparse checkout:This downloads only the repository structure, not file contents.
2
Configure Sparse Checkout
Sets which folder to checkout:Only files in the specified folder are downloaded.
3
Move Folder Contents
The folder contents are moved to the build root:
4
Build and Deploy
The folder contents are built and deployed as if they were the repository root.
Complete Build Worker Implementation
Frombuildworker.js:
Deployment Examples
Static Site in Monorepo
Node.js API in Monorepo
Nested Folder Structure
Monorepo Structures Supported
Nx Workspace
Turborepo
Lerna
Yarn Workspaces
Updating Folder Settings
Update folder configuration via the settings API:Benefits
Faster Cloning
Sparse checkout only downloads the files you need:- Full clone: Downloads entire repository history and all files
- Sparse checkout: Downloads only specified folder with
--filter=blob:none
Reduced Build Time
Smaller directory = faster builds:Lower Resource Usage
Less disk space and memory required for builds.Redeployment with Folders
The redeploy worker also supports folder deployments:Troubleshooting
Folder Not Found
Check your repository structure:Build Fails After Folder Deploy
- Verify
package.jsonexists in the folder - Check that all dependencies are properly referenced
- Ensure relative imports work from the folder root
Sparse Checkout Not Working
- Verify Git version supports sparse checkout (Git 2.25+)
- Check that
--filter=blob:noneis supported - Ensure folder name doesn’t have trailing slashes
Dependencies in Parent Directory
If your folder needs files from parent directories:Best Practices
Self-Contained Folders
Ensure each deployable folder has its own
package.json and dependenciesRelative Imports
Use path aliases for shared code instead of
../../ importsBuild Scripts
Keep build commands in the folder’s
package.jsonEnvironment Variables
Use folder-specific env vars to avoid conflicts
Next Steps
Branch Management
Configure branch selection and commit tracking
Static Sites
Deploy React, Vue, Angular apps
Node.js Apps
Deploy Express, Nest.js backends