Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include `.scss` file in another `.scss` file?

Tags:

sass

scss-lint

How can I Include .scss file in another .scss file? I was trying to write this in a file: app.scss:

@include('buttons'); @include('dropzone');  body {      background: $primaryColor;     overflow-x: hidden; /*Clip the left/right edges of the content inside the <div> element - if it overflows the element's content area: */     height: 100%; /* Cover all (100%) of the container for the body with its content */     padding-top: 70px; } /* more css code here */ 

and it returns an error : invalid css after @import

I try to include 2 other scss files inside the main scss file, so it will be all compiled to one css file eventually. How is it possible?

like image 424
osherdo Avatar asked Aug 01 '16 23:08

osherdo


People also ask

How do I link a SCSS file to another SCSS file?

You can use @use rule for it. This rule loads another Sass file as a module, which means you can refer to its variables, mixins, and functions in your Sass file with a namespace based on the filename. Using a file will also include the CSS it generates in your compiled output!

Can you import SCSS into sass?

The Sass @import directive extends the CSS @import rule so that it works with . scss and . sass files. It imports the file referenced and any variables or mixins that are defined in the imported file so they can be used in the main file.

How do I import a SCSS file into CSS?

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.


1 Answers

You can import it like this;

@import "../../_variables";  @import "../_mixins";  @import "_main";  @import "_login";  @import "_exception";  @import "_utils";  @import "_dashboard";  @import "_landing"; 

According to your directories and it will do what you want.

like image 198
Mertcan Diken Avatar answered Sep 24 '22 15:09

Mertcan Diken