jacquescrocker / jammit-sinatra

Jammit Rack middleware for use with Sinatra/Padrino
MIT License
23 stars 13 forks source link

Unable to turn off packaging in development mode #3

Open bilus opened 12 years ago

bilus commented 12 years ago

It seems that packaging is always on, even if RACK_ENV environment variable is set to "development".

In development mode I expect include_stylesheets and include_javascripts to render individual link/script markup code and use non-minified scripts. Is my assumption correct?

Perhaps I'm doing something wrong but I've found that Jammit.set_package_assets uses Rails module to check what is the current environment:

  # Turn asset packaging on or off, depending on configuration and environment.
  def self.set_package_assets(value)
    package_env     = !defined?(Rails) || (!Rails.env.development? && !Rails.env.test?)
    @package_assets = value == true || value.nil? ? package_env :
                      value == 'always'           ? true : false
  end

Quick& dirty code that takes care of the issue (when active in development mode only):

  module Rails
    class Env
      def development?
        true
      end
    end
    def self.env
      Env.new
    end
  end