6

I am getting below error while adding below styles in index.html in Angular 6 application.

Refused to apply the style from 'http://localhost:1234/node_modules/primeicons/primeicons.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

  <link rel="stylesheet" type="text/css" href="/node_modules/primeicons/primeicons.css" />
  <link rel="stylesheet" type="text/css" href="/node_modules/primeng/resources/themes/nova-light/theme.css" />
  <link rel="stylesheet" type="text/css" href="/node_modules/primeng/resources/primeng.min.css" />

How should I fix this error?

TheParam
  • 10,113
  • 4
  • 40
  • 51
Chandra sekhar
  • 356
  • 2
  • 12

2 Answers2

10

Instead of adding style in your index.html add it in your style.css file like below

Style.css

  @import '~primeicons/primeicons.css';
  @import '~primeng/resources/themes/nova-light/theme.css';
  @import '~primeng/resources/primeng.min.css';

Hop this will help!

TheParam
  • 10,113
  • 4
  • 40
  • 51
2

You have several options, how to import styles.

Import to CSS

styles.css

@import '~primeicons/primeicons.css';
@import '~primeng/resources/themes/nova-light/theme.css';
@import '~primeng/resources/primeng.min.css';

Or add them to angular.json

You can also add them to the angular.json file.

{
 ...
   "projects": {
    "yourProjectName": {
      ...
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/SkolniPanely",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.png",
              "src/assets",
              "src/manifest.json"
            ],
            "styles": [
              //Here you can add *.css files
            ],
            "scripts": [
              //Here you can add *.js files
            ]
          },
          ...
joka00
  • 2,357
  • 1
  • 10
  • 27