rstacruz / sinatra-assetpack

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

Sass @import not reloaded #139

Closed Awea closed 10 years ago

Awea commented 10 years ago

I'm using the following application.sass file :

@import "global/var"
@import "global/mixin"

@import "layout/bootstrap.css"
@import "layout/layout"

@import "dev/dev"
@import "dev/shame"

With the following configuration :

set :sass, { :load_paths => [ 
    "#{self.root}/public/stylesheets"
  ]}

  register Sinatra::AssetPack

  assets {
    serve '/javascripts', from: 'public/javascripts'
    serve '/stylesheets', from: 'public/stylesheets'
    serve '/images',      from: 'public/images'

    js :app, '/javascripts/app.js', [
      '/javascripts/libs/*.*'
    ]

    css :app, '/stylesheets/app.css', [
      '/stylesheets/application.css'
    ]

    js_compression  :jsmin
    css_compression :simple
  }

It work well. But when I change something in an included sass file, I need to save the application.sass too to get the changes.

j15e commented 10 years ago

This bug is a feature of sass, not a bug of sinatra-assetpack. See #102 also.

Awea commented 10 years ago

May be it can be solve using some Sprockets stuff. Or using an other gem like https://github.com/kalasjocke/sinatra-asset-pipeline.

leebrooks0 commented 10 years ago

Here is how I solved the problem using Guard Shell (https://github.com/hawx/guard-shell). Note that it is important that your 'manifest' file is not watched, or you will end up in an infinite loop.

# Workaround for https://github.com/rstacruz/sinatra-assetpack/issues/139
# Note: As of writing this, Guard-Shell gem needs file permissions loosened:
# https://github.com/hawx/guard-shell/issues/14
guard :shell do
  watch (%r{^app/assets/stylesheets/(.*)/(.*)\.scss}) do |m|
    # Notify me that the file has changed
    puts m[0] + " has changed."

    manifest = "#{ Dir.pwd }/app/assets/stylesheets/application.scss"
    command = "touch #{ manifest }"
    puts command # Nice to see in the terminal, Guard is a developer tool after all...

    `#{ command }`
  end
end
Awea commented 10 years ago

@leebrooks0 Seems good ! This issue is not related to this gem but to our environment of development. So I close it ^^

rolandjitsu commented 10 years ago

@Awea :+1: Helpful solution, perhaps should be added to README.md.