Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refused to apply style from 'http://localhost:1234/node_modules/primeicons/primeicons.css' because its MIME type ('text/html')

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?

like image 948
Chandra sekhar Avatar asked Mar 13 '19 09:03

Chandra sekhar


2 Answers

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
            ]
          },
          ...
like image 29
Josef Katič Avatar answered Nov 15 '22 13:11

Josef Katič


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!

like image 66
TheParam Avatar answered Nov 15 '22 11:11

TheParam