rstacruz / sinatra-assetpack

Package your assets transparently in Sinatra.
http://ricostacruz.com/sinatra-assetpack/
MIT License
542 stars 97 forks source link

Cannot specify SASS compression style #153

Open calvinwyoung opened 10 years ago

calvinwyoung commented 10 years ago

I'm working on a project with Sinatra + Sinatra-Assetpack, but the I can't seem to specify the SASS compression style. I've added css_compression :sass, :style => :compressed to the end of my assets configuration block, but the outputted CSS is not compressed. Setting any other value for the :style option doesn't work either.

I've already seen this StackOverflow post, but it wasn't helpful. I also couldn't find any information anywhere else.

I've made a sample projects with the following files:

Here are the contents of each file.

app.rb:

require "rubygems"
require "sass"
require "sinatra"
require "sinatra/assetpack"

assets do
  serve "/css", :from => "assets/css"

  css :application, [
    "/css/styles.css"
  ]

  css_compression :sass, :style => :compressed
end

get "/" do
  erb :index
end

index.erb:

<!DOCTYPE html>
<html lang="en">
    <head>
        <%= css :application %>
    </head>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>

styles.scss:

body {
    background: red;
    h1 {
        font-weight: bold;
    }
}

The outputted styles.css file looks like this:

body {
  background: red; }
  body h1 {
    font-weight: bold; }

This output corresponds to the default :nested output style, not the :compressed output style.

Setting the compression type to :styles => :expanded produces the same result, as does removing the option altogether.

Has anyone else experienced a similar issue? If so, how did you resolve it?

j15e commented 10 years ago

Default style should be compress :

https://github.com/rstacruz/sinatra-assetpack/blob/master/lib/sinatra/assetpack/engines/sass.rb#L4

But also it seems like @css_compression_options isn't used at all from a quick code survey.

calvinwyoung commented 10 years ago

Hmm...it does seem as though the default should be :compresed. Why on earth is it actually producing :nested output?

For reference, here are the relevant packages / versions from my bundle: