I have a rails project which uses twitter bootstrap and sass. The scss files are structured into folders so I have a better overview. Now I want to define a file for global variables which contains my colors etc. and pass those values down to other files so I have less redundant code. While all code is properly imported and applied, variables don't work.
Here is the current setup:
stylesheets/application.css.scss
/*
*= require_self
*= require_tree
*/
/*
stylesheets/
|
|– base/
| |– _reset.scss # Reset/normalize
| |– _typography.scss # Typography rules
|
|– components/
| |– _buttons.scss # Buttons
| |– _messages.scss # Nachrichten
| |– _dropdown.scss # Dropdown
|
|– helpers/
| |– _globals.scss # Sass Variables
| |– _functions.scss # Sass Functions
| |– _mixins.scss # Sass Mixins
| |– _helpers.scss # Class & placeholders helpers
//more files omitted
|
|– vendors/
| |– _bootstrap_and_overrides.css # Bootstrap
| |– _scaffolds.scss # Bootstrap
|
|
`– main.scss # primary Sass file
*/
I'm not using the =require method as it does not allow the use of variables and mixins (which I'd like to use).
I also use a main.scss which contains all the imports. stylesheets/main.scss
@import "bootstrap-sprockets";
@import "bootstrap";
@import "helpers/globals";
@import "base/normalize";
@import "base/grid";
@import "base/typography";
@import "components/buttons";
@import "components/tables";
//other files omitted
The helpers/globals.scss contains the color definitions: stylesheets/helpers/globals.scss
$background-light : #4e4d4a;
The file component/tables.scss is supposed to use that variable.
.table-striped > tbody > tr:nth-child(2n+1) > {
tr, td, th {
background-color: $background-light;
}
}
According to most information on the web and the official SASS-guide this should work as I declared the variable and import the according file before the file that uses it. Certainly, the variable is not found:
Undefined variable: "$background-light"
.
The whole procedure seems rather simple but I'm running out of ideas. Do I need to set something in my environment files or do I need to change my application.css.scss? Or might bootstrap interfere here?
Thanks in advance for your help.
@import "base/normalize"
since bootstrap ships with it own. – max