简体   繁体   English

在 Angular 中包含共享资产

[英]Include Shared Assets In Angular

I have create a angular workspace which host multiple angular projects and libraries.我创建了一个 angular 工作区,其中包含多个 angular 项目和库。

In workspace I have a shared library which contains all assets(images and logos).在工作区中,我有一个包含所有资产(图像和徽标)的共享库。

"assets": [
              "projects/xxx-workspace/src/favicon.ico",
              "projects/xxx-workspace/src/assets",
              "projects/xxx-shared/src/lib/images"
          ]

"projects/xxx-shared/src/lib/images" “项目/xxx-shared/src/lib/images”

But while building the application it throws error:-但是在构建应用程序时它会抛出错误:-

asset path must start with the project source root.资产路径必须以项目源根目录开头。

What is the expected configuration to achieve this.实现这一目标的预期配置是什么。

Hope you got this figured out.希望你明白这一点。 There is a cookbook article about this on nrwl connect https://connect.nrwl.io/app/cookbook/3lUhYk6aXO4kiKqfTfj3fs .在 nrwl connect https://connect.nrwl.io/app/cookbook/3lUhYk6aXO4kiKqfTfj3fs上有一篇关于此的食谱文章。 In short, angular cli doesn't let you reference assets outside the project source in that syntax, so to do this you can use this syntax https://angular.io/guide/workspace-config#assets-configuration简而言之,angular cli 不允许您以该语法引用项目源之外的资产,因此为此您可以使用此语法https://angular.io/guide/workspace-config#assets-configuration

  "assets": [
    {
      "input": "libs/my-lib/src/lib/assets",
      "glob": "*.png",
      "output": "assets"
    }
  ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM