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?
If you are using Sass in a Rails project, the sass-rails gem, https://github.com/rails/sass-rails, features glob importing.
To answer the concern in another answer "If you import a directory, how can you determine import order? There's no way that doesn't introduce some new level of complexity."
Some would argue that organizing your files into directories can REDUCE complexity.
My organization's project is a rather complex app. There are 119 Sass files in 17 directories. These correspond roughly to our views and are mainly used for adjustments, with the heavy lifting being handled by our custom framework. To me, a few lines of imported directories is a tad less complex than 119 lines of imported filenames.
To address load order, we place files that need to load first – mixins, variables, etc. — in an early-loading directory. Otherwise, load order is and should be irrelevant... if we are doing things properly.
You could use a bit of workaround by placing a sass file in folder what you would like to import and import all files in that file like this:
file path:main/current/_current.scss
@import "placeholders"; @import "colors";
and in next dir level file you just use import for file what imported all files from that dir:
file path:main/main.scss
@import "EricMeyerResetCSSv20"; @import "clearfix"; @import "current";
That way you have same number of files, like you are importing the whole dir. Beware of order, file that comes last will override the matching stiles.
this worked fine for me
I also search for an answer to your question. Correspond to the answers the correct import all function does not exist.
Thats why I have written a python script which you need to place into the root of your scss folder like so:
It will then walk through the tree and find all scss files. Once executed, it will create a scss file called main.scss
an example of an output file:
This feature will never be part of Sass. One major reason is import order. In CSS, the files imported last can override the styles stated before. If you import a directory, how can you determine import order? There's no way that doesn't introduce some new level of complexity. By keeping a list of imports (as you did in your example), you're being explicit with import order. This is essential if you want to be able to confidently override styles that are defined in another file or write mixins in one file and use them in another.
For a more thorough discussion, view this closed feature request here:
With defining the file to import it's possible to use all folders common definitions.
So,
@import "style/*"
will compile all the files in the style folder.More about import feature in Sass you can find here.