GithubHelp home page GithubHelp logo

Comments (17)

johnmcdowall avatar johnmcdowall commented on August 19, 2024 6

register_engine has been deprecated in Sprockets 3, so I had to use the following initializer to work with Rails 5 and Sprockets 4:

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

from sassc-rails.

rstacruz avatar rstacruz commented on August 19, 2024 3

I have a cleaner workaround to propose:

# Gemfile
gem 'sass-rails', require: false
gem 'sassc-rails'

This ensures that sass-rails is not automatically require'd, making sassc-rails take over. This of course won't work if a gem explicitly requires sass-rails.

from sassc-rails.

pinzonjulian avatar pinzonjulian commented on August 19, 2024 3

Hi! Has a permanent fix for this issue been made? I really want to use SassC in my project!

from sassc-rails.

bolandrm avatar bolandrm commented on August 19, 2024 2

@constantm I've released version 0.0.6, which I believe addressed this problem. If you have both installed, sassc-rails should override sass-rails. Please give it a shot and let me know how it goes!

from sassc-rails.

bolandrm avatar bolandrm commented on August 19, 2024 1

updated to this:

# 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

Rails.application.config.assets.configure do |env|
  env.register_engine '.sass', SassC::Rails::SassTemplate
  env.register_engine '.scss', SassC::Rails::ScssTemplate
end

from sassc-rails.

bolandrm avatar bolandrm commented on August 19, 2024

Hey! This gem is very much a work in progress. Your mileage may vary.

It seems that your project isn't using sassc-rails to compile. Could you try some of the following:

  • remove sass-rails
  • after bundling, double check that sass-rails is not present
  • remove cache assets folder
  • spring stop? restart server?

from sassc-rails.

constantm avatar constantm commented on August 19, 2024

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 sass-rails with sassc and it works perfectly now. Obviously that's not the best way to go about doing things - is there some way that you're aware of to do this in a more sustainable way?

from sassc-rails.

bolandrm avatar bolandrm commented on August 19, 2024

I had to revert the changes here, i'm trying this out:

in an initializer: config/initializers/sassc_rails.rb

Rails.application.assets.register_engine '.sass', SassC::Rails::SassTemplate
Rails.application.assets.register_engine '.scss', SassC::Rails::ScssTemplate

from sassc-rails.

bolandrm avatar bolandrm commented on August 19, 2024

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

from sassc-rails.

bolandrm avatar bolandrm commented on August 19, 2024

i'd welcome anyone else's thoughts on a more permanent solution - do we simply include the about in the sassc-rails railtie?

from sassc-rails.

brainopia avatar brainopia commented on August 19, 2024

@bolandrm here you go :)

from sassc-rails.

bolandrm avatar bolandrm commented on August 19, 2024

Testing against my rails project, this issue does not seem to be resolved yet.

from sassc-rails.

brainopia avatar brainopia commented on August 19, 2024

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) .
If yes, then tell me what rails version do you use? And then I'll check whether a different railtie loading mechanism is used there compared to latest rails.

from sassc-rails.

rstacruz avatar rstacruz commented on August 19, 2024

The workaround doesn't help for me, btw. I've placed it in config/initializers, register_engine never gets called for Sass::Rails.

from sassc-rails.

mibamur avatar mibamur commented on August 19, 2024

@bolandrm last comment
and

gem 'sass-rails', require: false
gem 'sassc-rails', github: 'sass/sassc-rails'

worked fine

from sassc-rails.

wesley6j avatar wesley6j commented on August 19, 2024

config/initializers/sassc_rails.rb does not work for me. It has conflicts with slim-rails. Since in my project the only gem that requires sass-rails is activeadmin, I updated the dependency of activeadmin and it works really well: activeadmin with sassc-rails

from sassc-rails.

Marcellllll avatar Marcellllll commented on August 19, 2024

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.

from sassc-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.