Don P
Don P

Reputation: 63577

Sprockets prevents SASS variable and mixins

Can Sprockets use global SASS variables and mix-ins?

It seems so strange that Rails ships with both Sprockets and SASS, but doesn't let you use SASS variables and mixins.

Here is an example: I have 1 global file named "font_colors.sass" that has all of my font color variables. Then I do a single @import font_colors in my main SASS file, like application.css.sass. Then all other imports in application.css.sass can use my @imported font_colors! Sweet.

But that's not the case with Sprockets...

Due to Sprockets, it seems like I would have to do @import font_colors in every SASS file that wants it. This is a lot of repetition. Does anyone else have this problem?

Upvotes: 0

Views: 639

Answers (1)

Philip Hallstrom
Philip Hallstrom

Reputation: 19879

Yes. It's "the way it is" unfortunately. I can't remember where (sass or rails docs) but somewhere it talks about this and advises that if you're using SASS to use it all the way.

Downside is you lose the ability to pinpoint the exact sass file the styles are coming from in development as it results in a single css file, but the upside is if you have a lot of little sass files (i like to isolate things) then it won't break in older versions of IE in development when you hit the nasty "sorry, i won't load more than 31 css files" bug.

Upvotes: 1

Related Questions