【问题标题】:Angular-cli- Unable to bundle font-awesomeAngular-cli-无法捆绑字体真棒
【发布时间】:2017-04-12 18:46:38
【问题描述】:

我已经构建了我的 Angular2 应用程序,一切正常。现在我包含了 font-awesome,当我捆绑应用程序时,它给出了图片中显示的错误。无法加载 woff 和 woff2 文件。 我的样式如下所示 -

            "styles": [
        "styles.css",
          "../node_modules/font-awesome/css/font-awesome.css",
          "../node_modules/primeng/resources/primeng.min.css",
  "../node_modules/primeng/resources/themes/omega/theme.css",
  "../node_modules/fullcalendar/dist/fullcalendar.css",
  "../node_modules/bootstrap/dist/css/bootstrap.min.css"
      ],

【问题讨论】:

  • 图片在哪里?
  • 刚刚更新了。
  • 你必须在你的问题中包括你如何在你的模块中导入它,否则人们无能为力。
  • 按照建议,我将它包含在我的“样式”中:[“../node_modules/font-awesome/css/font-awesome.css”,]。当我发球时它工作正常。控制台中不会引发错误。仅当我在 IIS 上进行构建和手动部署时才会出错。
  • 用我的 angular-cli.json - Styles 属性更新了问题。

标签: angular angular-cli font-awesome-5


【解决方案1】:

由于文件夹结构在最近的角度版本中发生了变化,您应该指的是错误的路径修复它

"styles": [
    "styles.css",
      "node_modules/font-awesome/css/font-awesome.css",
      "node_modules/primeng/resources/primeng.min.css",
      "node_modules/primeng/resources/themes/omega/theme.css",
      "node_modules/fullcalendar/dist/fullcalendar.css",
      "node_modules/bootstrap/dist/css/bootstrap.min.css"
  ],

【讨论】:

  • 但是当我做服务并且所有图标都正确显示时它工作正常,控制台也是空的。问题仅在于我进行构建时。
  • 你试过这个答案吗?
  • 是的。它抛出错误。因为它无法解析相对路径。我还在问题中添加了项目结构截图供您参考。
  • 您的应用的配置文件在哪里?
  • 你真是太好了 Aravind。不幸的是我现在不能来teamviewer。您是否在我们的项目中包含了 font-awesome 和 Primeng 并在控制台中正确捆绑它而没有任何错误。
猜你喜欢
  • 2017-06-26
  • 1970-01-01
  • 2017-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-01
  • 2014-12-12
  • 2014-03-07
相关资源
最近更新 更多