How Scully Works
Scully is a static site generator designed specifically for Angular applications. It takes your Angular app, analyzes its structure, and pre-renders all known routes into static HTML files that can be served without requiring JavaScript to display content.Core Architecture
Scully operates through a multi-phase build process that transforms your dynamic Angular application into a collection of static files:Configuration Loading
Scully compiles and loads your
scully.<projectName>.config.ts file along with any custom plugins defined in the ./scully directory.Route Discovery
The system analyzes your Angular application to identify all routes, including lazy-loaded modules and parameterized routes.
Route Enrichment
Each discovered route is enriched with configuration data and transformed from an unhandled route into a handled route with all necessary metadata.
Rendering
Each route is rendered using Puppeteer (by default) or a custom render plugin, generating the final HTML output.
Post-Processing
Render plugins process the HTML to add additional functionality, optimize content, or inject metadata.
The Build Pipeline
When you runnpx scully, the following sequence of operations occurs:
Phase 1: Initialization
Scully begins by:- Compiling user plugins - TypeScript files in
./scully/are compiled using./scully/tsconfig.json - Loading configuration - The
scully.<projectName>.config.tsfile is loaded and validated - Running beforeAll plugins - Any registered
beforeAllplugins are executed
The
beforeAll plugins are useful for setup tasks like database connections, API calls, or environment checks that need to complete before route discovery begins.Phase 2: Route Discovery
The route discovery process identifies all routes in your application:- Parses your Angular routing configuration using the
guess-parserlibrary - Identifies static routes (e.g.,
/about,/contact) - Discovers parameterized routes (e.g.,
/user/:id,/blog/:slug) - Merges in any
extraRoutesdefined in your configuration
Phase 3: Route Enrichment
Unhandled routes are transformed into handled routes:- Router plugins expand parameterized routes into concrete routes
- Configuration data is attached to each route
- Route type (content, JSON, etc.) is determined
- Custom metadata is added from plugins
Phase 4: Route Processing
Before rendering, routes pass through processing plugins:- Filter routes based on custom criteria
- Modify route metadata
- Add or remove routes from the list
- Transform route properties
Phase 5: Rendering
Each route is rendered to generate static HTML:Phase 6: Completion
After all routes are rendered:- The
scully.routes.jsonfile is written with metadata for all routes allDoneplugins are executed for post-processing tasks- Performance statistics are calculated and displayed
Plugin System
Scully’s architecture is highly extensible through its plugin system. There are several types of plugins:Router Plugins
Transform unhandled routes with parameters into concrete routes
Render Plugins
Control how routes are rendered into HTML
Route Process Plugins
Modify the list of routes before rendering
Post-Render Plugins
Process HTML after initial rendering
Plugin Execution Order
Caching and Performance
Scully implements intelligent caching to improve performance:Route Caching
Discovered routes are cached to avoid re-scanning the Angular application:Parallel Rendering
Scully renders routes in parallel using all available CPU cores:Background Server
When Scully starts, it automatically launches a background server to serve your Angular application during the rendering process:The background server runs on the port specified in your
scully.config.ts (default: 1668) and serves your pre-built Angular application from the dist folder.Performance Monitoring
Scully tracks detailed performance metrics throughout the build process:- Identify bottlenecks in your build process
- Optimize plugin performance
- Track improvements over time
--stats flag to generate a detailed scullyStats.json file with comprehensive timing information.
Next Steps
Now that you understand how Scully works, dive deeper into specific concepts:Route Discovery
Learn how Scully finds all routes in your application
Rendering Process
Understand how routes are transformed into static HTML
Handled Routes
Explore the structure and properties of handled routes
Unhandled Routes
Learn about parameterized and dynamic routes

