In addition to having a solid file structure, a big part of staying organized is splitting up the logic into smaller manageable components.
Sass extends the existing CSS
@import rule to allow including other SCSS and Sass files.
- Typically, all imported SCSS files are imported into a main SCSS file which is then combined to make a single CSS output file.
- The main/global SCSS file has access to any variables or mixins defined in its imported files. The `@import command takes a filename to import.
@import looks for a Sass file in the same or otherwise specified directory but there are a few circumstances where it will behave just like a CSS
- If the file’s extension is .css.
- If the filename begins with http://.
- If the filename is a url().
- If the
@import has any media queries.
In addition to keeping code organized, importing files can also save you from repeating code. For example, if multiple SCSS files reference the same variables, importing a file with variables partial would save the trouble of redefining them each time.