Can I import Partials into Partials in SASS?

Viewed 1492

I'm using Sass to style a new website.
Originally my style.scss (the main SCSS file which compiles) imported general.scss (where I defined variables) and the various pages (such as homepage.scss). It worked well. I than tried to refactor homepage.scss to just import Scss of its' various sections (such as section-a.scss). Surprisingly all the variables aren't recognized anymore by the Sass compiler (Prepros).

My questions are:

  1. Can I import partials into partials in SASS?
  2. Can I use variables declared in a partial which is imported to the main scss file (that which compiles) in all of the other partials?

Needless to say, all of the partial file names begin with an underscore.

Thanks!

3 Answers

This should be fine depending on your set up, just be sure to have your hierarchy set up in a way so that the imports flow logically so that you're not trying to access variables before they are defined and the likes.

That is more likely to be an issue if you're using a plugin / package that just grabs all the files from a folder at a time.

I normally just try to stick to having one file for importing everything in that way it is easier to manage. Each to their own though.

Related