@ angular-devkit / build-ng-packagr:build是否有任何可配置的选项?

时间:2019-06-01 20:02:45

标签: angular npm ng-packagr

我正在使用Angular CLI来构建/打包我的组件库,我想包括项目 root 中的README.md而不是projects文件夹中的文件

所以我想看看构建器是否有任何配置选项,但是Wiki上没有任何发布。

这是我发现的:https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_ng_packagr/README.md

我想在我的angular.json中添加用于构建库的选项。

        "build": {
          "builder": "@angular-devkit/build-ng-packagr:build",
          "options": {
            "tsConfig": "library/tsconfig.lib.json",
            "project": "library/ng-package.json",
            // add options here!
          }
        },

关于packagr存储库的文档,没有Wiki。

https://github.com/ng-packagr/ng-packagr

我的另一种选择是查看此构建器的JSON模式,但我不知道如何读取它。

  

ngPackagr的构建器是否具有可配置的选项?

1 个答案:

答案 0 :(得分:0)

它似乎仅支持watch参数进行配置。模式位于此处:

https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_ng_packagr/src/build/schema.json

查看源代码,也没有其他选择(代码中没有使用watch)。

async function initialize(
  options: NgPackagrBuilderOptions,
  root: string,
): Promise<import ('ng-packagr').NgPackagr> {
  const packager = (await import('ng-packagr')).ngPackagr();

  packager.forProject(resolve(root, options.project));

  if (options.tsConfig) {
    packager.withTsConfig(resolve(root, options.tsConfig));
  }

  return packager;
}

https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_ng_packagr/src/build/index.ts

相关问题