plugin
Theplugin schematic (also available as add-plugin) creates a custom Scully plugin for extending Scully’s functionality with router or render plugins.
Usage
Basic Usage
Short Form
Using Alias
Interactive Mode
If you don’t provide all required options, you’ll be prompted:Options
--name (required)
- Type:
string - Description: The name of the plugin
- Prompt: “What name do you want to use for the plugin?”
- The plugin filename (dasherized)
- The plugin function name (camelized)
- Plugin registration identifier
scully-plugins/custom-router.plugin.js
--pluginType (required)
- Type:
string - Options:
"router","render" - Description: The type of plugin to create
- Prompt: “What type of plugin do you want to create?”
--project
- Type:
string - Default:
"defaultProject" - Description: The project to create the plugin in (for multi-project workspaces)
What Gets Created/Modified
The plugin schematic creates a plugin file and registers it in your Scully configuration.1. Router Plugin
File:[sourceRoot]/scully-plugins/[plugin-name].plugin.js
For a router plugin named “customRouter”:
File: src/scully-plugins/custom-router.plugin.js
2. Render Plugin
File:[sourceRoot]/scully-plugins/[plugin-name].plugin.js
For a render plugin named “customRenderer”:
File: src/scully-plugins/custom-renderer.plugin.js
3. Scully Configuration Update
File:scully.[project].config.ts (or scully.config.ts)
The schematic automatically adds a require statement at the top of your Scully config:
Before:
Plugin Types
Router Plugins
Router plugins discover and generate routes for Scully to render. They return an array ofHandledRoute objects.
Use cases:
- Fetching routes from an API
- Generating routes from a database
- Creating dynamic route variations
- Custom route parameter resolution
Render Plugins
Render plugins transform the rendered HTML after Scully captures it. They receive HTML as a string and return modified HTML. Use cases:- Adding analytics scripts
- Injecting meta tags
- Transforming content
- Adding CSS/JS resources
- Minifying HTML
Examples
Creating a Router Plugin
Creating a Render Plugin
Multi-Project Workspace
Plugin File Location
Plugins are created in thescully-plugins directory within your project’s source root:
Naming Conventions
The schematic applies these transformations to your plugin name:-
File name: Dasherized (kebab-case)
- Input:
myCustomPlugin - File:
my-custom-plugin.plugin.js
- Input:
-
Function name: Camelized (camelCase)
- Input:
my-custom-plugin - Function:
myCustomPlugin
- Input:
-
Registration name: Camelized
- Input:
MyCustomPlugin - Registered as:
myCustomPlugin
- Input:
Validator Function
Both plugin templates include a validator function. Use this to validate plugin configuration:Plugin Registration Types
The schematic registers plugins with specific types:| Plugin Type | Registration Type | Purpose |
|---|---|---|
| router | 'router' | Route discovery and generation |
| render | 'postProcessByHtml' | HTML transformation after rendering |
'render'- Render process plugins'routeProcess'- Route processing plugins'allDone'- Post-build plugins'routeDiscoveryDone'- After route discovery plugins
Testing Your Plugin
After creating a plugin:- Implement the plugin logic in the generated file
-
Configure the plugin in
scully.config.ts: -
Add to post-renderers (for render plugins):
-
Build and run Scully:
-
Check the output in the
dist/staticdirectory
Common Issues
Plugin Not Loading
Ensure the require statement is at the top ofscully.config.ts:
Plugin Not Found
Verify the plugin is registered with the correct name:Async Issues
Router plugins must return a Promise or use async/await:See Also
- ng-add schematic - Initial Scully installation
- Plugin System - Learn about Scully’s plugin architecture
- Router Plugins - Router plugin documentation
- Render Plugins - Render plugin documentation

