Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to @import .css file as a .scss file in sass?

Tags:

css

sass

I am using gulp as a task runner which merge and minifying scss files for me. In this case if I try to import a regular CSS file, it will compile to a css import statement as below:

/* style.scss */
@import "../../bower_components/animate.css/animate.css";

/* style.css */
@import url(../../bower_components/animate.css/animate.css);

So how to import that regular css file, to have a compiled version of that in the style.css instead of just css @import statement?

like image 594
bobsilon Avatar asked Mar 11 '17 07:03

bobsilon


People also ask

How do I import a CSS file into SCSS?

It is now possible to import css files directly into your sass file. The following PR in github solves the issue. The syntax is the same as now - @import "your/path/to/the/file" , without an extension after the file name. This will import your file directly.

Can we use CSS in SCSS file?

scss files, Sass can import plain old . css files. The only rule is that the import must not explicitly include the . css extension, because that's used to indicate a plain CSS @import .

How do I import a Sass file into another Sass file?

sass or . scss file. You can also import CSS files. The @import directive imports the file and any variables or mixins defined in the imported file can then be used in the main file.

Is @import deprecated in Sass?

The @import rule, and most global functions will eventually be deprecated, and then removed from Sass.


1 Answers

Simply do this:

/* style.scss */
@import "../../bower_components/animate.css/animate";

Just don't write file extension, Import the file without the extension, the compiler will put the file content in style.css instead of putting @import rule.

like image 192
bobsilon Avatar answered Sep 21 '22 08:09

bobsilon