rails / sass-rails

Ruby on Rails stylesheet engine for Sass

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variables are not available in a file named "_elements.text.scss"

tomsabin opened this issue · comments

Our project is following a CSS architecture called ITCSS. We have files prepended with the layer they're declared at, e.g. Settings and Elements.

_settings.colors.scss contains sass variables. It is loaded before other partials.

_elements.paragraphs.scss use the variables declared above. All is well, until I rename this file to _elements.text.scss, then all of a sudden I get an "Undefined variable" error.

Please see the sample Rails application here: https://github.com/tomsabin/sass-rails-issue-391.

tomsabin/sass-rails-issue-391@1f378cd adds the working version with _elements.paragraphs.scss. You can point HEAD to this commit and see the Rails application is working fine.

Then, check out the latest commit tomsabin/sass-rails-issue-391@203110e and restart the server. You should see the Undefined variable: "$color-grey-light". error.

(I was not able to recreate it with just the sass gem)

I have kind of the same problem with a file named variables.scss. I can see it's compiled, but variables are not availables to other files. If I'm importing manually the variable.scss file in the other files, it works.

I don't know if the pb is from sass or from the rails asset pipeline.

looks like it's linked to that rails/rails#28628

For anyone that stumbles upon this issue, I think I have narrowed it down to the use of the word 'text' as a filename after _elements.. My suspicion is that Sass is treating the .text part of the file name as some kind of file extension and for whatever reason the variables are not being defined.

Strangely, if I comment out the variable definitions, refresh the page and then uncomment out the variable definitions and refresh the page again, they then start working.

I discovered this bug when creating a file called _helpers.text.scss in the same codebase @tomsabin initially discovered this issue in.

@tomsabin curious if you ever figured this out and/or found out what's actually going on? Especially the fact that I can get it working by commenting -> refreshing -> uncommenting -> refreshing! 😱

@tomsabin curious if you ever figured this out and/or found out what's actually going on? Especially the fact that I can get it working by commenting -> refreshing -> uncommenting -> refreshing! 😱

I'm afraid not 😞