在 Angular 中包含共享资产 [英] Include Shared Assets In Angular

查看:36
本文介绍了在 Angular 中包含共享资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个 Angular 工作区,其中包含多个 Angular 项目和库.

I have create a angular workspace which host multiple angular projects and libraries.

在工作区中,我有一个包含所有资产(图像和徽标)的共享库.

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"

但是在构建应用程序时它抛出错误:-

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.

推荐答案

希望你能解决这个问题.在 nrwl connect https://connect.nrwl.io/app/cookbook 上有一篇关于此的食谱文章/3lUhYk6aXO4kiKqfTfj3fs.简而言之,angular cli 不允许您以该语法引用项目源之外的资产,因此为此您可以使用此语法 https://angular.io/guide/workspace-config#assets-configuration

Hope you got this figured out. There is a cookbook article about this on 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

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

这篇关于在 Angular 中包含共享资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆