2

I've got a normal website of files on my local machine and would like to use Sass. In the <head> of my index page I have:

<link rel="stylesheet" type="text/css" href="stylesheets/style.scss" />

Though when I run this in Chrome I get an error in the console:

Resource interpreted as Stylesheet but transferred with MIME type text/plain coming from the link tag in index.

How can I change the meme type so Chrome renders my Sass styles?

KatieK
  • 13,586
  • 17
  • 76
  • 90
Connor Leech
  • 18,052
  • 30
  • 105
  • 150

4 Answers4

10

text/x-sass and text/x-scss, according to https://github.com/janlelis/rubybuntu-mime/blob/master/sass.xml

Know that this will not make a web browser compile it to CSS for you as they do not contain a SASS parser/compiler. The only use case for this would be a template that is intended to be transformed via a configured HTML parser.

Steven Vachon
  • 3,814
  • 1
  • 30
  • 30
  • What is the purpose of the `x` prefix? I know this is sometimes used for non-standard HTTP headers, is there such a thing as a non-standard mimetype? – exciteabletom May 06 '21 at 03:49
4

Don't think you can insert SASS right into your web page. There must be some SASS preprocessor first. That gives you a normal CSS file.

iiic
  • 1,366
  • 2
  • 15
  • 23
  • 1
    You could theoretically have an HTML document with a ` – Steven Vachon Nov 30 '16 at 16:25
4
  1. Are you sure you want to use plain Scss as a stylesheet, without any compilation, in your page?
  2. Tell your http server to use "text/css" as the content-type for your *.scss files (see related Chrome says "Resource interpreted as script but transferred with MIME type text/plain.", what gives?)
Community
  • 1
  • 1
Alexander Pavlov
  • 31,598
  • 5
  • 67
  • 93
0

In your particular case the issue is that you are linking a scss file in your html and chrome can not interpret scss.

What you needs to do is use the pre processor in sass to turn the files from sass to css. You can do the following open your terminal and open the directory where your scss is stored and run the sass --watch main.scss main.css this will process your scss to the css you need and keep checking for changes. In this case my sass file is name main.scss and it will turn my sass to css in the main.css file.

After this is done what you need to do is link the css file in your html and it should work make sure you point to the correct file.