Skip to content

Angular Libraries

Mike Goodstadt edited this page May 29, 2019 · 5 revisions

Generate ngx-resizable in Projects

ng generate library ngx-resizable --prefix=tk

Generate new component in library

ng generate component component-name --prefix tk --project ngx-resizable --export

Build library

ng build ngx-resizable

Using Libraries within other Libraries

2 steps:

  1. Add relative paths to tsconfig.lib.json (see stackoverflow):
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    ...
    "baseUrl": "./",
    "paths": {
        "ngx-resizable": [
            "../../dist/ngx-resizable"
        ],
        "ngx-resizable/*": [
            "../../dist/ngx-resizable/*"
        ]
    }
    ...
  }
}
  1. Add umdModuleIds to ng-package.json (see ng-packagr docs):
{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  "dest": "../../dist/ngx-resizable",
  "deleteDestPath": false,
  "lib": {
    "entryFile": "src/public_api.ts",
    "umdModuleIds": {
      "ngx-resizable": "NgxResizable"
    }
  }
}