Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Support bootstrap-sass and font-awesome-sass gems (ie. *= require bootstrap in directive) #17

Open
wakatara opened this issue Mar 5, 2014 · 8 comments

Comments

@wakatara
Copy link

wakatara commented Mar 5, 2014

This can probably be more generalized to apply to anything that would end up in the vendor path, but after working with this for an evening, I'm a little stumped how to get padrino-pipeline (which I'm loving btw, very nice work) to use these two gems, both of which would be extremely nice to use along with the pipelining in padrino -- minimally with sprockets at the very least.

Am I just being dense here or is there a way to get p-p to ingest and use these two things?

(furthermore, I'm assuming there is also no way to pipeline font directory assets either? Looking in the code the asset paths supported seem to be only images, javascripts and stylesheets.).

@Ortuna
Copy link
Owner

Ortuna commented Mar 6, 2014

Thanks for the kind words!

I will take a look at this in the next few days. I believe the load paths need to be sync'd up here

@leemour
Copy link

leemour commented Mar 17, 2014

+1 For bootstrap-sass support. When using \= require 'bootstrap' in my application.js I get:

Sprockets::FileNotFound at /
couldn't find file 'bootstrap' (in .../app/assets/js/application.js:1)

Is there an easy fix for adding bootstrap-sass path to pipeline?

@Ortuna
Copy link
Owner

Ortuna commented Mar 17, 2014

Hey guys I did some work on this today. The gem should now support basic external sprocket configurations. But alot of these external gems are doing things differently from each other 😦. But I did add an example here on how to use paths from here. It does require some digging into code, but not too much. Let me know if this is acceptable.

@leemour
Copy link

leemour commented Mar 17, 2014

That works, thanks a lot!

@pdf
Copy link

pdf commented Mar 26, 2014

Here's my ugliness for dealing with this so I can use rails-assets:

    configure_assets do |assets|
      assets.pipeline = Padrino::Pipeline::Sprockets
      assets.js_assets = [assets.js_assets] unless assets.js_assets.is_a?(Array)
      assets.css_assets = [assets.css_assets] unless assets.css_assets.is_a?(Array)
      assets.image_assets = [assets.image_assets] unless assets.image_assets.is_a?(Array)

      # Load assets from gems
      $:.each do |path|
        assets_base = File.join(path, '..', 'vendor', 'assets')
        %w{javascripts stylesheets images}.each do |type|
          dir = File.join(assets_base, type)
          if File.directory?(dir)
            case type
            when 'javascripts'
              assets.js_assets << dir
            when 'stylesheets'
              assets.css_assets << dir
            when 'images'
              assets.image_assets << dir
            end
          end
        end
      end
    end

But with bootstrap-sass, now my app is exploding because of #22

@Ortuna
Copy link
Owner

Ortuna commented Mar 27, 2014

@pdf, Would it possible to do a PR with your fix? Also, do you have the output of your bootstrap-sass app that explodes? Thanks!

@pdf
Copy link

pdf commented Mar 27, 2014

@Ortuna, I don't know that this is an optimal fix generally, but it will work with any gem that puts assets in gem_dir/vendor/assets/{javascript|stylesheets|images}. If you think that's good enough, I can submit a PR for it.

Here's the output from the sass font failure (actually from rails-assets-bootstrap, not bootstrap-sass):

  FATAL -  Sprockets::NotImplementedError - Custom asset_path helper is not implemented

Extend your environment context with a custom method.

    environment.context_class.class_eval do
      def asset_path(path, options = {})
      end
    end

  (in /storage/workspace/lifxfx/app/assets/stylesheets/bootstrap_and_overrides.css.scss):
  sprockets (2.12.0) lib/sprockets/context.rb:241:in `asset_path'
  sprockets (2.12.0) lib/sprockets/context.rb:261:in `font_path'
  sprockets (2.12.0) lib/sprockets/sass_functions.rb:42:in `font_url'
  sass (3.3.4) lib/sass/script/tree/funcall.rb:140:in `_perform'
  sass (3.3.4) lib/sass/script/tree/node.rb:50:in `perform'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:366:in `visit_prop'
  sass (3.3.4) lib/sass/tree/visitors/base.rb:36:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:152:in `block in visit'
  sass (3.3.4) lib/sass/stack.rb:79:in `block in with_base'
  sass (3.3.4) lib/sass/stack.rb:121:in `with_frame'
  sass (3.3.4) lib/sass/stack.rb:79:in `with_base'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:152:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:470:in `block (2 levels) in visit_directive'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:470:in `block in visit_directive'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:173:in `with_environment'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:469:in `visit_directive'
  sass (3.3.4) lib/sass/tree/visitors/base.rb:36:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:152:in `block in visit'
  sass (3.3.4) lib/sass/stack.rb:79:in `block in with_base'
  sass (3.3.4) lib/sass/stack.rb:121:in `with_frame'
  sass (3.3.4) lib/sass/stack.rb:79:in `with_base'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:152:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:297:in `block (2 levels) in visit_import'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:297:in `block in visit_import'
  sass (3.3.4) lib/sass/stack.rb:88:in `block in with_import'
  sass (3.3.4) lib/sass/stack.rb:121:in `with_frame'
  sass (3.3.4) lib/sass/stack.rb:88:in `with_import'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:294:in `visit_import'
  sass (3.3.4) lib/sass/tree/visitors/base.rb:36:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:152:in `block in visit'
  sass (3.3.4) lib/sass/stack.rb:79:in `block in with_base'
  sass (3.3.4) lib/sass/stack.rb:121:in `with_frame'
  sass (3.3.4) lib/sass/stack.rb:79:in `with_base'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:152:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:297:in `block (2 levels) in visit_import'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:297:in `block in visit_import'
  sass (3.3.4) lib/sass/stack.rb:88:in `block in with_import'
  sass (3.3.4) lib/sass/stack.rb:121:in `with_frame'
  sass (3.3.4) lib/sass/stack.rb:88:in `with_import'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:294:in `visit_import'
  sass (3.3.4) lib/sass/tree/visitors/base.rb:36:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:152:in `block in visit'
  sass (3.3.4) lib/sass/stack.rb:79:in `block in with_base'
  sass (3.3.4) lib/sass/stack.rb:121:in `with_frame'
  sass (3.3.4) lib/sass/stack.rb:79:in `with_base'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:152:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
  sass (3.3.4) lib/sass/tree/visitors/base.rb:52:in `visit_children'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:161:in `block in visit_children'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:173:in `with_environment'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:160:in `visit_children'
  sass (3.3.4) lib/sass/tree/visitors/base.rb:36:in `block in visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:180:in `visit_root'
  sass (3.3.4) lib/sass/tree/visitors/base.rb:36:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:151:in `visit'
  sass (3.3.4) lib/sass/tree/visitors/perform.rb:8:in `visit'
  sass (3.3.4) lib/sass/tree/root_node.rb:36:in `css_tree'
  sass (3.3.4) lib/sass/tree/root_node.rb:20:in `render'
  sass (3.3.4) lib/sass/engine.rb:274:in `render'
  sprockets (2.12.0) lib/sprockets/sass_template.rb:53:in `evaluate'
  tilt (1.4.1) lib/tilt/template.rb:103:in `render'
  sprockets (2.12.0) lib/sprockets/context.rb:197:in `block in evaluate'
  sprockets (2.12.0) lib/sprockets/context.rb:194:in `evaluate'
  sprockets (2.12.0) lib/sprockets/processed_asset.rb:12:in `initialize'
  sprockets (2.12.0) lib/sprockets/base.rb:374:in `block in build_asset'
  sprockets (2.12.0) lib/sprockets/base.rb:395:in `circular_call_protection'
  sprockets (2.12.0) lib/sprockets/base.rb:373:in `build_asset'
  sprockets (2.12.0) lib/sprockets/index.rb:94:in `block in build_asset'
  sprockets (2.12.0) lib/sprockets/caching.rb:51:in `cache_asset'
  sprockets (2.12.0) lib/sprockets/index.rb:93:in `build_asset'
  sprockets (2.12.0) lib/sprockets/base.rb:287:in `find_asset'
  sprockets (2.12.0) lib/sprockets/index.rb:61:in `find_asset'
  sprockets (2.12.0) lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
  sprockets (2.12.0) lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
  sprockets (2.12.0) lib/sprockets/processed_asset.rb:97:in `build_required_assets'
  sprockets (2.12.0) lib/sprockets/processed_asset.rb:16:in `initialize'
  sprockets (2.12.0) lib/sprockets/base.rb:374:in `block in build_asset'
  sprockets (2.12.0) lib/sprockets/base.rb:395:in `circular_call_protection'
  sprockets (2.12.0) lib/sprockets/base.rb:373:in `build_asset'
  sprockets (2.12.0) lib/sprockets/index.rb:94:in `block in build_asset'
  sprockets (2.12.0) lib/sprockets/caching.rb:51:in `cache_asset'
  sprockets (2.12.0) lib/sprockets/index.rb:93:in `build_asset'
  sprockets (2.12.0) lib/sprockets/base.rb:287:in `find_asset'
  sprockets (2.12.0) lib/sprockets/index.rb:61:in `find_asset'
  sprockets (2.12.0) lib/sprockets/bundled_asset.rb:16:in `initialize'
  sprockets (2.12.0) lib/sprockets/base.rb:377:in `build_asset'
  sprockets (2.12.0) lib/sprockets/index.rb:94:in `block in build_asset'
  sprockets (2.12.0) lib/sprockets/caching.rb:51:in `cache_asset'
  sprockets (2.12.0) lib/sprockets/index.rb:93:in `build_asset'
  sprockets (2.12.0) lib/sprockets/base.rb:287:in `find_asset'
  sprockets (2.12.0) lib/sprockets/index.rb:61:in `find_asset'
  sprockets (2.12.0) lib/sprockets/environment.rb:75:in `find_asset'
  sprockets (2.12.0) lib/sprockets/base.rb:295:in `[]'
  padrino-pipeline (0.4.0) lib/padrino-pipeline/pipelines/sprockets.rb:64:in `block in mount_assets'
  padrino-core (0.12.0) lib/padrino-core/application/routing.rb:698:in `block in route'
  padrino-core (0.12.0) lib/padrino-core/application/routing.rb:62:in `block (3 levels) in process_destination_path'
  sinatra (1.4.4) lib/sinatra/base.rb:976:in `route_eval'
  padrino-core (0.12.0) lib/padrino-core/application/routing.rb:62:in `block (2 levels) in process_destination_path'
  padrino-core (0.12.0) lib/padrino-core/application/routing.rb:62:in `block in process_destination_path'
  padrino-core (0.12.0) lib/padrino-core/application/routing.rb:37:in `process_destination_path'
  (eval):93:in `block in call'
  (eval):82:in `call'
<snipped remaining stack>

I can probably hack around that by:

assets.context_class.class_eval do
  def asset_path(path, options = {})
    "/assets/#{path}"
  end
end

or something, but I haven't had time to test this properly.

@Ortuna
Copy link
Owner

Ortuna commented Mar 29, 2014

@pdf I'm wondering if it's a load order issue? Because I a variation of the code here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants