Overview
ng-packagr is a tool that allows you to compile and package Angular libraries in the Angular Package Format (APF). It is used to build distribution-ready npm packages from TypeScript sources.
Features
- Implements Angular Package Format
- Bundles your library in FESM2022 format
- npm package can be consumed by Angular CLI, Webpack, or ESM Bundlers
- Creates type definitions (.d.ts)
- Creates scoped and non-scoped packages for publishing to npm registry
- Inlines Templates and Stylesheets
- Runs SCSS preprocessor, supporting custom include paths
- Adds vendor-specific prefixes with autoprefixer and browserslist
- Embeds assets data with postcss-url
Installation
To install ng-packagr, you can use npm or yarn. Here is an example of how to install it using npm:
npm install ng-packagr --save-dev
Summary
ng-packagr is a powerful tool for compiling and packaging Angular libraries. It follows the Angular Package Format specification and provides a range of features to simplify the process of creating distribution-ready npm packages. With ng-packagr, you can easily bundle your library, create type definitions, and publish your packages to the npm registry.