bootstrap.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. module Sprockets
  2. class Bootstrap
  3. def initialize(app)
  4. @app = app
  5. end
  6. # TODO: Get rid of config.assets.enabled
  7. def run
  8. app, config = @app, @app.config
  9. return unless app.assets
  10. config.assets.paths.each { |path| app.assets.append_path(path) }
  11. if config.assets.compress
  12. # temporarily hardcode default JS compressor to uglify. Soon, it will work
  13. # the same as SCSS, where a default plugin sets the default.
  14. unless config.assets.js_compressor == false
  15. app.assets.js_compressor = LazyCompressor.new { Sprockets::Compressors.registered_js_compressor(config.assets.js_compressor || :uglifier) }
  16. end
  17. unless config.assets.css_compressor == false
  18. app.assets.css_compressor = LazyCompressor.new { Sprockets::Compressors.registered_css_compressor(config.assets.css_compressor) }
  19. end
  20. end
  21. if config.assets.compile
  22. app.routes.prepend do
  23. mount app.assets => config.assets.prefix
  24. end
  25. end
  26. if config.assets.digest
  27. app.assets = app.assets.index
  28. end
  29. end
  30. end
  31. end