Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compass and sass: possible to auto-import all partials? [duplicate]

In a compass/sass setup, ideally I would like to compile every .scss-file into one big style.css. Looking e.g. here, it seems my only option would be to make _partials.scss and @import "these"; from one main file. This seems like double work, since every time I move around a .scss-file e.g. to a sub folder I have to update the referenced import-path.

My question is: is it possible with compass instead to just watch a folder and always compile all partials into one single target output file?

like image 333
Frederik Struck-Schøning Avatar asked Dec 19 '12 14:12

Frederik Struck-Schøning


People also ask

What is difference between @USE and @import in SCSS?

Fundamentally both rules do the same thing - load members inside another module. The main differences is how they handle members. @import makes everything globally accessible in the target file.

How do you use partials in Sass?

Sass Partials scss files directly. However, when you want to import a file, you do not need the file to be transpiled directly. Sass has a mechanism for this: If you start the filename with an underscore, Sass will not transpile it. Files named this way are called partials in Sass.

Is @import deprecated in Sass?

In brief, @import is being replaced with more explicit @use and @forward rules. Over the next few years Sass @import will be deprecated, and then removed. You can still use CSS imports, but they won't be compiled by Sass.

How do I declare partials in Sass?

A partial is simply an Sass file preceded by an underscore. An example is _name-of-file. scss . The underscore tells Sass that the file is a partial and that it should not be compiled to CSS.


1 Answers

Use the Sass Globbing Plugin.

This way you can import an entire folder:

@import "library/partials/*"

The partials will be sorted alphabetically before being imported.

like image 185
bookcasey Avatar answered Sep 20 '22 20:09

bookcasey