I am modularizing my stylesheets with SASS partials like so:
@import partials/header
@import partials/viewport
@import partials/footer
@import partials/forms
@import partials/list_container
@import partials/info_container
@import partials/notifications
@import partials/queues
is there a way to include the whole partials directory(it's a directory full of SASS-partials) like @import compass or something?
The accepted answer by Dennis Best states that "Otherwise, load order is and should be irrelevant... if we are doing things properly." This is simply incorrect. If you are doing things properly, you make use of the css order to help you reduce specificity and keeping you css simple and clean.
What I do to organize imports is adding an
_all.scss
file in a directory, where I import all the relevant files in it, in the correct order. This way, my main import file will be simple and clean, like this:You could do this for sub-directories as well, if you need, but I don't think the structure of your css files should be too deep.
Though I use this approach, I still think a glob import should exist in sass, for situations where order does not matter, like a directory of mixins or even animations.
http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#import
doesn't look like it.
If any of these files always require the others, then have them import the other files and only import the top-level ones. If they're all standalone, then I think you're going to have to keep doing it like you are now.
You might want to retain source order then you can just use this.
I prefer this.
Check out the sass-globbing project.
I create a file named
__partials__.scss
in the same directory ofpartials
In
__partials__.scss
, I wrote these:So, when I want import the whole
partials
, just write@import "partials"
. If I want import any of them, I can also write@import "partials/header"
.