jaspr build command compiles your Jaspr project for production deployment, generating optimized assets and executables.
Basic Usage
build/jaspr/ and varies based on your project’s rendering mode.
Output Structure
The build output varies by rendering mode:- Server Mode
- Static Mode
- Client Mode
- Copy entire
build/jaspr/directory to your server - Run the executable:
./app(orapp.exeon Windows) - Set
PORTenvironment variable as needed
Server Build Options
These options apply when building in server mode:Specify the server entry point file. Must end in Defaults to:
.server.dart.lib/main.server.dart- First
*.server.dartfile inbin/ - First
*.server.dartfile inlib/
Specify the compilation target for the server executable.Options:
exe- Self-contained executableaot-snapshot- AOT snapshot (requires Dart runtime)jit-snapshot- JIT snapshot (requires Dart runtime)
- Executable (exe)
- AOT Snapshot
- JIT Snapshot
Compiles to a standalone executable.Pros:
- No Dart runtime required
- Single file deployment
- Fastest startup time
build/jaspr/app.exe (Windows) or build/jaspr/app (Linux/macOS)Cross-Compilation
Compile for a specific operating system.Options:
linux, macos, windowsCompile for a specific CPU architecture.Options:
arm, arm64, riscv64, x64Web Compilation Options
Set the dart2js/dart2wasm optimization level.Options:
0- No optimizations (debugging only)1- Basic optimizations and inlining2- Production optimizations (recommended)3- Potentially unsafe optimizations4- Aggressive unsafe optimizations
- Level 0
- Level 1
- Level 2 (Default)
- Level 3
- Level 4
No optimizations - for compiler debugging only.Use: Only when debugging the Dart compiler itself
Compile to WebAssembly instead of JavaScript.Output:
main.dart.wasm instead of main.dart.jsInclude source maps and Dart source files in the build output.Useful for debugging production issues, but increases bundle size.
Static Site Generation
These options apply when building in static mode:Generate a Output includes:
sitemap.xml file with the specified domain.Regex pattern of routes to exclude from the sitemap.Excludes routes matching the pattern from
sitemap.xml.Sitemap Configuration
Control sitemap generation from your components:lib/pages/home.dart
Build Configuration
Let Jaspr manage build_runner configuration automatically.Disable to manually configure builders.
Dart Defines
Pass compile-time constants to your application:Define environment variables for both client and server.
Load dart-define variables from a JSON file.
prod-config.json
Complete Examples
Deployment Guides
Server Mode Deployment
Server Mode Deployment
Static Site Deployment
Static Site Deployment
Deploy to static hosting:
- Netlify
- Vercel
- GitHub Pages
netlify.toml
Docker Deployment
Docker Deployment
Containerize your server application:Build and run:
Dockerfile
Build Performance
Typical build times:- Client mode: 10-15 seconds
- Server mode: 15-25 seconds (exe), 10-15 seconds (aot-snapshot)
- Static mode: 20-40 seconds (depends on number of routes)
Troubleshooting
Build fails with errors
Build fails with errors
Clean build artifacts and rebuild:
Large bundle size
Large bundle size
Check your optimization level:Analyze bundle size:
Cross-compilation fails
Cross-compilation fails
Ensure you’re using a compatible target:
Static generation incomplete
Static generation incomplete
Check that all routes are discovered:
- Ensure routes are linked from the home page
- Check server logs for errors during generation
- Use
--verbosefor detailed output
Next Steps
Deployment
Learn about deploying Jaspr applications
Production Tips
Optimize for production environments
Serve Command
Learn about the development server
Docker
Containerize your application