【问题标题】:Angular PrimeIcons work locally but not on IISAngular PrimeIcons 在本地工作,但不在 IIS 上
【发布时间】:2020-08-10 14:11:03
【问题描述】:

我在我的 Angular 应用程序中使用 primeicons 和 primeng。

如果我在本地运行 Angular 网站/应用程序,一切都很好。

但部署到 IIS 服务器时,图标不显示 - 但所有其他样式运行良好。

这是 IIS 配置中的内容吗?

代码中的

用法

<i class="pi pi-exclamation-circle">
angular.json 中的

样式

"styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "node_modules/primeicons/primeicons.css",
              "node_modules/primeng/resources/themes/nova-light/theme.css",
              "node_modules/primeng/resources/primeng.min.css",
              "node_modules/primeflex/primeflex.css",
              "src/styles.less"                            
            ],

依赖项在 package.json 中:

"dependencies": {
    "@angular/animations": "^9.1.12",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "^9.1.12",
    "@angular/compiler": "^9.1.12",
    "@angular/core": "^9.1.12",
    "@angular/forms": "^9.1.12",
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "^9.1.12",
    "@angular/platform-browser-dynamic": "^9.1.12",
    "@angular/router": "^9.1.12",
    "angular2-jwt": "^0.2.3",
    "bootstrap": "^4.5.2",
    "chart.js": "^2.9.3",
    "moment": "^2.27.0",
    "primeflex": "^1.3.1",
    "primeicons": "^3.0.0",
    "primeng": "^9.1.3",
    "rxjs": "~6.5.4",
    "tslib": "^1.13.0",
    "zone.js": "~0.10.2"
  },

【问题讨论】:

  • 什么是字体文件扩展名(例如 woff、woff2.ttf 等),您的 IIS 配置是否允许这样做...字体文件通常位于 build/deply 文件夹的根目录中跨度>

标签: angular iis angular-cli primeng primeicons


【解决方案1】:

解决方案是在 web.config 中为 woff 和 ttf 文件添加例外:

<?xml version="1.0" encoding="utf-8"?>
  <configuration>
    <system.webServer>
      <rewrite>
        <rules>
          <rule name="SPA" stopProcessing="true">
            <match url="^(?!.*(\.js|\.css|\.png|\.jpg|\.ico|\.svg|\.ttf|\.woff|\.eot)).*$" />
            <conditions logicalGrouping="MatchAll" />
            <action type="Rewrite" url="/"  appendQueryString="true" />
          </rule>
        </rules>
      </rewrite>
    </system.webServer>
  </configuration>

【讨论】:

  • 如果您的问题得到解决,我请求您将有用的建议标记为答案。这将帮助面临同样问题的其他人。
  • 抱歉,错过了:-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-10-22
  • 1970-01-01
  • 1970-01-01
  • 2021-08-04
  • 2013-11-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多