Karthik
Karthik

Reputation: 1161

Angular 6 - Refused to apply style from '...' because its MIME type ('text/html') is not a supported stylesheet

Trying to upgrade to Angular 6 and got the below error when I referred the below in index.html:

Refused to apply style from 'https://localhost:44394/~/assets/primengcss/themes/omega//theme.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Upvotes: 7

Views: 12473

Answers (1)

Karthik
Karthik

Reputation: 1161

Found the answer (at least worked for me), after some digging around:

Looks like inAngular 6 we need to include any external CSS (like bootstrap, fontawesome, Primeng etc.,) to the angular.json as below:

        "styles": [
          "./node_modules/bootstrap/dist/css/bootstrap.min.css",
          "./node_modules/font-awesome/css/font-awesome.min.css",
          "src/styles.css",
          "./node_modules/primeng/resources/themes/omega/theme.css",
          "./node_modules/primeng/resources/primeng.min.css",
          "./node_modules/primeicons/primeicons.css"
        ],
        "scripts": [
          "./node_modules/jquery/dist/jquery.slim.min.js",
          "./node_modules/popper.js/dist/umd/popper.min.js",
          "./node_modules/bootstrap/dist/js/bootstrap.min.js"
        ]   

Upvotes: 6

Related Questions