Angular
Knapsack for Angular works by scanning your specified Angular code locations and automatically discovering reusable components, making them instantly available in your design system.
Why This Approach:
- ⚡ Zero Manual Work - Knapsack finds and configures your components automatically
- 🔄 Always Current - Your documentation stays in sync with code changes
- 🎯 Intelligent - Understands different export patterns and component structures
- 🚀 Scale Effortlessly - Handle hundreds of components without individual setup
Requirements
- Angular 17 or later - The Angular renderer requires Angular 17+ and will exit with an error if an older version is detected
- Built packages - Components must be built into packages using ng-packagr
- Package paths only - Local TypeScript files are not supported
Important: The Angular renderer only supports built packages created with ng-packagr. Local TypeScript files are not supported. Ensure your Angular components are built into proper packages before using them with Knapsack.
Install
Configure
Minimal Setup
The simplest configuration requires specifying your Angular package:
Full Configuration Example
Here’s a comprehensive example showing all available options:
Code Sources
The codeSrcs array tells Knapsack where to find your Angular components. Only package paths are supported - the renderer will scan these packages and make Angular components available in the Knapsack UI.
Built Packages
Package Sub-paths
Smart Filtering
Use filters to control exactly which components are discovered:
Custom NgModule Path
The customNgModulePath configuration option specifies the path to a custom Angular module that is imported into Knapsack alongside the main renderer application.
1. Create a Custom Module:
Create a file (e.g., ks.module.ts):
2. Add your Module Path
Reference your module in the renderer configuration:
Package Path Aliases
The pkgPathAliases configuration provides path aliases for monorepo packages:
Wrapper Component
The wrapperComponentPath configuration option specifies the path to a custom component that wraps all of your Angular component demos.
1. Create a Wrapper Component:
Create a file (e.g., demo-wrapper.component.ts):
2. Add your Wrapper Path
Reference your wrapper in the renderer configuration: