rstacruz / sinatra-assetpack

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

SASS is being served uncompiled and uncompressed: #135

Open arman-h opened 10 years ago

arman-h commented 10 years ago

sinatra-assetpack is serving SASS in plain-text format, with no conversion or compression. I have arranged the assets differently than shown in the examples:

./app.rb
./config.ru
./Gemfile
./Gemfile.lock
./assets
./assets/css
./assets/css/style.sass
./assets/img
./assets/js
./assets/js/app.js

but I have also made changes to reflect the correct asset structure in app.rb:

class MyApp < Sinatra::Base
    enable :inline_templates
    register Sinatra::AssetPack
    assets do
        serve '/js', :from => 'assets/js'
        serve '/css', :from => 'assets/css'

        js :app, [
            '/js/app.js'
        ]

        css :app, [
            '/css/style.sass',
        ]

        js_compression :jsmin
        css_compression :sass
    end

    get '/' do
        haml :index
    end

end

__END__

@@ layout
!!!
%html{:lang => "en"}
    %head
        != css :app
    %body
        = yield
        != js :app

@@ index
%h1 Hello World!

And here's the output:

<!DOCTYPE html>
<html lang='en'>
  <head>
    <link rel='stylesheet' href='/css/style.sass' />
  </head>
  <body>
    <h1>Hello World!</h1>
    <script src='/js/app.74be16979710d4c4e7c6647856088456.js'></script>
  </body>
</html>

I'm using Ruby 1.9.3, and my Gemfile / Gemfile.lock files look like this:


# Gemfile
source 'https://rubygems.org'
gem 'sinatra'
gem 'thin'
gem 'haml'
gem 'sass'
gem 'sinatra-assetpack', :require => 'sinatra/assetpack'

# Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    daemons (1.1.9)
    eventmachine (1.0.3)
    haml (4.0.3)
      tilt
    jsmin (1.0.1)
    rack (1.5.2)
    rack-protection (1.5.0)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    sass (3.2.10)
    sinatra (1.4.3)
      rack (~> 1.4)
      rack-protection (~> 1.4)
      tilt (~> 1.3, >= 1.3.4)
    sinatra-assetpack (0.3.1)
      jsmin
      rack-test
      sinatra
      tilt (>= 1.3.0)
    thin (1.5.1)
      daemons (>= 1.0.9)
      eventmachine (>= 0.12.6)
      rack (>= 1.0.0)
    tilt (1.4.1)

PLATFORMS
  ruby

DEPENDENCIES
  haml
  sass
  sinatra
  sinatra-assetpack
  thin
eka commented 10 years ago

Did you solve this?

I think you should change this:

css :app, [
            '/css/style.css',
        ]

and the style.sass will be converted automatically