在 Angular 库中保留符号链接

and*_*ves 13 npm npm-link angular angular8 angular-cli-v8

我有个问题。

我正在尝试使用 ng-cli 创建一个 Angular 8 库,但我无法使用npm link.

我试图在我的 angular.json 上添加这个:

    "build": {
      "builder": "@angular-devkit/build-ng-packagr:build",
      "options": {
        "preserveSymlinks": true,
        "tsConfig": "projects/button/tsconfig.lib.json",
        "project": "projects/button/ng-package.json"
      }
    }, 
Run Code Online (Sandbox Code Playgroud)

但得到:

"Schema validation failed with the following errors: Data path ""
should NOT have additional properties(preserveSymlinks)."
Run Code Online (Sandbox Code Playgroud)

我发现它不适用于图书馆。

然后我尝试将其添加到我的 tsconfig.lib.json 中:

 "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true,
    "preserveSymlinks": true
  }
Run Code Online (Sandbox Code Playgroud)

什么也没发生。

我在这里搜索了一个解决方案,但找不到类似的东西。

我怎样才能做到?

谢谢!

Arm*_*rez 21

我相信您需要在位于将使用您的库的项目中的 angular.json 中添加 preserveSymlinks 选项。例如,我在本地进行测试,并将其添加到我的架构师 -> 构建 -> 选项中。

您可以在此处找到更多信息:https : //dev.to/nieds/getting-started-building-component-libraries-with-angular-cli-4ncj

希望这可以帮助!