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
@importhas 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.
Analyze the file architecture currently set up for the project by clicking on the file icon on the top left hand corner of your code editor. You will be using this to navigate between files.
The lemonade stand is a smaller project, so we have only set up a helper folder. As it grows, we could add partials for
_components and more!