0

I have used Bower to install a selection of components into my Rails app.

The components are in /app/vendor/assets/components

I have installed the hidpi scss file and that lives at:

/app/vendor/assets/components/sass-hidpi/_hidpi.scss

Now, I need to get that scss file imported into my main application.css.sass file which lives in /app/assets/stylesheets

I have tried:

@import url(<%= asset_path '_hidpi.scss' %>)

by adding .erb onto the end of my application.css.sass file but that just outputs:

@import "/assets/_hidpi.scss" in my compiled stylesheet which obviously is wrong.

How can I get the file imported and compiled without moving it from the components directory that bower installs to?

rctneil
  • 7,016
  • 10
  • 40
  • 83

1 Answers1

2

You can try adding the following to config/application.rb, inside the class Application < Rails::Application block:

config.sass.load_paths << File.expand_path('../../vendor/assets/components/')

from SASS, Rails 3.1: Loading stylesheets in vendor/assets

Community
  • 1
  • 1
flyingjamus
  • 3,975
  • 2
  • 16
  • 13
  • Thanks. I already had config.assets.paths << Rails.root.join("vendor", "assets", "components") set in application.rb but that made no difference. The line you posted gave the following error too: environment.rb:7:in `': undefined local variable or method `config' for main:Object (NameError) – rctneil May 27 '13 at 12:22
  • I changed the answer to include the `.configure do` part. You add it before the `.initialize!` line. – flyingjamus May 27 '13 at 12:51
  • Ok, so that allows my app to run but the mixin still cannot be located. It seems like Sass is not looking in the right locations for the file: Sass::SyntaxError at / File to import not found or unreadable: hidpi.scss. Load paths: Sass::Rails::Importer(/Users/neil/code/neil.co.uk/app/assets/stylesheets/application.css.sass.erb) /Users/neil/code/neil.co.uk/app/assets/stylesheets /Users/neil/code/neil.co.uk/vendor/ruby/2.0.0/gems/compass-0.12.2/frameworks/blueprint/stylesheets – rctneil May 27 '13 at 12:59
  • I guess it only works if you want to include it using the asset pipeline. Changed it again. Sorry. – flyingjamus May 27 '13 at 13:13
  • This worked perfectly! config.sass.load_paths << File.expand_path('vendor/assets/components/') Thankyou so much. Highly appreciated – rctneil May 27 '13 at 13:27