Skip to content

Sass::SyntaxError: Invalid CSS when running tests #93

Open
@jankeesvw

Description

@jankeesvw

Hello, I'm doing a project where I use material_components_web-sass which requires me to use Sassc. I ran into a problem and after some digging I found an issue with sassc-rails's railtie. I found this code in railtie.rb:

initializer :setup_compression, group: :all do |app|
  if !Rails.env.development?
    app.config.assets.css_compressor = :sass unless app.config.assets.has_key?(:css_compressor)
  else
    # Use expanded output instead of the sass default of :nested unless specified
    app.config.sass.style ||= :expanded
  end
end

Turns out sassc-rails does something different in the !Rails.env.development? environments.

What I did to workaround this problem was to set a value in the css_compressor so it doest get overwritten.

So by adding this to my config/environments/test.rb the problems went away:

# Set a css_compressor so sassc-rails does not overwrite the compressor when running the tests
config.assets.css_compressor = nil

Is there a reason there is different behavior for non-development environments? Otherwise I would love to propose a pull request to change this code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions