Dry approach in bootstrap-sass: should I import user variables before or after _variables.scss?

I am running my own bootstrap-sass setup in a fairly large project. In my git registry, I have my own application.scssfile that reflects the original one bootstrap.scss, deleting what I don't need and adding my own custom variables, mixins and styles.

I cannot figure out the right way to do this, while maintaining the DRY approach. Do i have @import 'application/variables';to before or after i @import 'path/to/bootstrap/variables';?

To approach

This is apparently the preferred method for bootstrap developers, because all variables declared in _variables.scssare followed by a flag !defaultthat only takes effect if the variable was previously declared.

Where is this going? Take, for example, this declaration:

$brand-primary: $gray;

Compiling this SASS code spits out an error undeclared variablebecause it $grayis defined in bootstrap _variables.scss, which is then imported. If I want this to work, I will have to re-declare $grayat the top of my file, even if it has not changed from the default.

This may not seem like a big problem, but at a certain level of complexity it starts to happen quite a lot, and your application/_variables.scssmoves from the “file in which I define my own variables” to the “file where I define my variables and copy some other boot files without changing them.

Sequential approach

, . , , . :

$padding-base-vertical: 8px;

, ? . ? , , $input-height-base, bootstrap _variables.scss, $padding-base-vertical.

$input-height-base:

$input-height-base: ($line-height-computed + ($padding-base-vertical * 2) + 2) !default;

, $input-height-base $padding-base-vertical , . ( , ).

""? Redeclare $input-height-base application/_variables.scss , . , .


, ? , , , .

, .

+4
1

, . , .

, - . , . ( , ). . (@import s) , , .

, " Bootstrap" - bootstrap-declarations bootstrap-styles ( , /mixins ). @import bootstrap-declarations variables - , @import . (), @import variables , @import of bootstrap-styles, .

0

All Articles