-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems when other gems depend on sass-rails #6
Comments
Hey! This gem is very much a work in progress. Your mileage may vary. It seems that your project isn't using
|
Had a quick look and it seems that sass-rails is still getting included because of ActiveAdmin's dependency on it. I forked ActiveAdmin and replaced the dependencies on |
@constantm I've released version |
I had to revert the changes here, i'm trying this out: in an initializer: Rails.application.assets.register_engine '.sass', SassC::Rails::SassTemplate
Rails.application.assets.register_engine '.scss', SassC::Rails::ScssTemplate |
I ran into some more issues with this. I had to add the following to the initializer in the previous comment: # config/initializers/sassc_rails.rb
require "sprockets/engines"
module Extensions
module Sprockets
module Engines
def register_engine(ext, klass)
return if [
Sass::Rails::SassTemplate,
Sass::Rails::ScssTemplate
].include?(klass)
super
end
end
end
end
Sprockets::Base.send(:prepend, Extensions::Sprockets::Engines)
Rails.application.assets.register_engine '.sass', SassC::Rails::SassTemplate
Rails.application.assets.register_engine '.scss', SassC::Rails::ScssTemplate |
i'd welcome anyone else's thoughts on a more permanent solution - do we simply include the about in the sassc-rails railtie? |
@bolandrm here you go :) |
Prevent sass-rails railtie from running, fixes #6
Testing against my rails project, this issue does not seem to be resolved yet. |
I can help to investigate. In my project the problem was that a sass rails initializer was setting up sprocket engines. In your case were sprocket engines pointing to sass instead of sassc? If so, than can you check separately whether sass-rails initializer was ran or not. If not then you need to track where they're registered from (like you did with your monkeypatch of register_engine) . |
The workaround doesn't help for me, btw. I've placed it in |
I have a cleaner workaround to propose: # Gemfile
gem 'sass-rails', require: false
gem 'sassc-rails' This ensures that |
updated to this:
|
@bolandrm last comment gem 'sass-rails', require: false
gem 'sassc-rails', github: 'sass/sassc-rails' worked fine |
Hi! Has a permanent fix for this issue been made? I really want to use SassC in my project! |
|
Rails.application.config.assets.configure do |env|
env.register_mime_type 'text/css', extensions: ['.scss'], charset: :css
env.register_mime_type 'text/css', extensions: ['.css.scss'], charset: :css
env.register_preprocessor 'text/css', SassC::Rails::ScssTemplate
end |
The initializer isn't working for me. I get an error: uninitialized constant SassC Any idea how I could fix this ? I would really like to use sassc. |
A Rails app is generated with a sass-rails dependency, so no changes to tests were needed -- the engine-cart-generated test app adds it's own sass-rails dependency. While current Rails releases generate with sass-rails dependency, sass-rails is sunsetted/deprecated, due to the underlying pure-ruby ruby-sass gem being deprecated, and instructs "consider switching to the sassc gem" /~https://github.com/sass/ruby-sass . Rails 6.0 will perhaps depend on the sassc-rails gem instead, or perhaps the sass-rails gem itself will be changed to depend on sassc instead of sass-ruby. I am not sure if it is yet determined/done. rails/rails#3289 But apps now may wish to switch to sassc-rails, especially if it's a new app. While sassc-rails _ought_ to be a drop-in replacement, bugs can happen, and the timeline of switching (or refraining from switching) should be up to a dependent app. However, if an app depends on both sass-rails and sassc-rails, problems can occur. sass/sassc-rails#6 So, removing the sass-rails as an explicit dependency from browse-everything will allow dependent apps to choose sass-rails or sassc-rails themselves, switching on their own timeline, without the browse-everything dependency interfering. This change is unlikely to pose any backwards compatibility problems, as dependent apps should have sass-rails in their Gemfile already, as it is generated by Rails. In the unlikely event some dependent app did not have sass-rails independently declared as a dependency, however, they would have to add it."
A Rails app is generated with a sass-rails dependency, so no changes to tests were needed -- the engine-cart-generated test app adds it's own sass-rails dependency. While current Rails releases generate with sass-rails dependency, sass-rails is sunsetted/deprecated, due to the underlying pure-ruby ruby-sass gem being deprecated, and instructs "consider switching to the sassc gem" /~https://github.com/sass/ruby-sass . Rails 6.0 will perhaps depend on the sassc-rails gem instead, or perhaps the sass-rails gem itself will be changed to depend on sassc instead of sass-ruby. I am not sure if it is yet determined/done. rails/rails#3289 But apps now may wish to switch to sassc-rails, especially if it's a new app. While sassc-rails _ought_ to be a drop-in replacement, bugs can happen, and the timeline of switching (or refraining from switching) should be up to a dependent app. However, if an app depends on both sass-rails and sassc-rails, problems can occur. sass/sassc-rails#6 So, removing the sass-rails as an explicit dependency from browse-everything will allow dependent apps to choose sass-rails or sassc-rails themselves, switching on their own timeline, without the browse-everything dependency interfering. This change is unlikely to pose any backwards compatibility problems, as dependent apps should have sass-rails in their Gemfile already, as it is generated by Rails. In the unlikely event some dependent app did not have sass-rails independently declared as a dependency, however, they would have to add it."
I've been struggling to get sassc to work with Rails for quite some time but with little luck. Tonight I thought I'd give it a try again, but a quick Google lead me to this repo. Woo!
Unfortunately I can't see any sort of increase in the speed that my scss files compile after changing them. Is there some extra configuration necessary after installing the gem?
The text was updated successfully, but these errors were encountered: