A
A
AlexanderKom2016-08-04 10:00:12
Sass
AlexanderKom, 2016-08-04 10:00:12

How to correctly include variables in several files?

Tell me how to use variables if I want to make styles for individual blocks in separate files, like this:

/scss  /*папка стилей*/
- main.scss /* главный файл стилей куда подключаю все остальные стили для блоков*/
- _header.scss /* файл стилей для хедера*/
- _content.scss /* файл стилей для блока*/
...
- _footer.scss /* файл стилей с футера */

What is the actual question, there are variables for the entire project, for example $base-font-size: 16;, I store such variables in main.scss , and when they are mentioned in included files, for example in _header.scss - I will get an error, they say _header.scss - does not know what $base is -font-size .
What to do? Should I put such variables in a separate file and do it @import "_project-variables.scss";in each included style? Somehow it doesn’t work .. Maybe you can tell me a more optimal method?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2016-08-04
@alexey-m-ukolov

Move such variables to a separate file and do Dmitrijs Balcers "_project-variables.scss"; in each plug-in style?
That's exactly what I'm doing. You can, for example, make mixins that use these variables and connect them, thus hiding the connection of the variables itself, but these are the same eggs, only on the side.
For Rails, there is a gem that allows you to import entire directories, but again - this does not save you from importing variables, it only simplifies it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question