rails / sass-rails

Ruby on Rails stylesheet engine for Sass

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

require vs. include

jjb opened this issue · comments

The changelog says:

Limit =require to .css only files and @import to .scss files. Avoid mixing the two.

I looked in the commit history logs and diffs and couldn't find where this change was introduced.

I'd like to know more about it. Why "avoid" -- isn't it a new requirement?

Sorry if I'm missing something obvious. If you can just point me to a commit or some docs I'll figure out the rest myself.

Thanks for a great project!

You should prefer @import since it actually pulls any mixins into the
current context. =require is sprockets specific and can't do that.
On Fri, Jan 16, 2015 at 1:33 PM John Bachir notifications@github.com
wrote:

The changelog
https://github.com/rails/sass-rails/blob/master/CHANGELOG.md says:

Limit =require to .css only files and @import to .scss files. Avoid
mixing the two.

I looked in the commit history logs and diffs and couldn't find where this
change was introduced.

I'd like to know more about it. Why "avoid" -- isn't it a new requirement?

Sorry if I'm missing something obvious. If you can just point me to a
commit or some docs I'll figure out the rest myself.

Thanks for a great project!


Reply to this email directly or view it on GitHub
#306.

Okay, thanks! But in what sense is this now Limited as the changelog says?

Previously did sass rails somehow attempt to also pull requireed assets into the current context, but now it doesn't?

This change silently broke our css that was being included by a bunch of our gem dependencies and took a while to track down the source. We're strictly defining the sass-rails version in our Gemfile for now (and probably should have been doing so from the start) but maybe it's safer to add a depreciation warning instead of just limiting right away? Alternatively a warning to the log for when an asset file is skipped would have been really useful. I'm sure we're not going to be the only people affected by this change!

Alternatively a warning to the log for when an asset file is skipped would have been really useful.

I looked into some warnings briefly. But that would have required using private sass APIs to inspect the contents of those imported files. Which was the reason for dropping support in the first place because we didn't want to depend on sass internals which have changed in the past.

We're strictly defining the sass-rails version in our Gemfile for now (and probably should have been doing so from the start)

Yeah, 5.0 was a major release, so it had backward incompatible changes.

I had an unexpected issue with this. I was @include something/in/vendor.css and it worked great in development. In production, the import was not replaced and was left as a css import. Obviously the vendor files didn't exist in production. Changing it to //= require something/in/vendor.css fixed it.

I have to be missing a concept here...

This is still a complete show stopper preventing me from using sass-rails 5.0 and hence sass > 3.3 in my engine. Please see my comment in this issue