Kathrin
Kathrin

Reputation: 13

configure size budgets for angular library

Is it possible to configure budget size on our own library defined in a multi-project workspace for angular 7?

See: https://angular.io/guide/build#configure-size-budgets

My project configuration in angular.json is like this, but there is no budget warning:

"projects": {
    "mylib": {
    ....
     "architect": {
        "build": {
          "builder": "@angular-devkit/build-ng-packagr:build",
          "options": {
            "tsConfig": "projects/ipi-ng-components/tsconfig.lib.json",
            "project": "projects/ipi-ng-components/ng-package.json"
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "anyScript",
                  "baseline": "10kb",
                  "maximumWarning": "20kb",
                  "maximumError": "50kb"
                }
              ]
            }
            ....
            }

    }

Upvotes: 1

Views: 807

Answers (1)

Tyler Mumford
Tyler Mumford

Reputation: 316

I think it's not supported right now. I've tried it, and I can't get it to work, even with a limit of 0kb. Also, the Angular docs indicate that there is a different build system for libraries:

The CLI build command uses a different builder and invokes a different build tool for libraries than it does for applications.

  • The build system for apps, @angular-devkit/build-angular, is based on webpack, and is included in all new Angular CLI projects.
  • The build system for libraries is based on ng-packagr. It is only added to your dependencies when you add a library using ng generate library my-lib.

In light of this, I've just opened a feature request on ng-packagr: Issue 1538.

I'm using Angular 8.

Upvotes: 1

Related Questions