Vince
Vince

Reputation: 4222

How do I include CSS from a gem using SASS instead of Sprockets?

I want to use the jquery-ui-rails gem in my rails project, but I'm using SASS imports for my CSS. How should I import the CSS for jQuery UI?

The css.erb files are under the Ruby installation path hierarchy and I guess the asset pipeline magic is making them available when I serve the app. I don't see them anywhere in my project path.

I understood that I should use the SASS @import statements exclusively instead of mixing them with Sprockets *= require directives.

Should I use the jquery-ui-sass-rails gem, or is that redundant since the CSS files are already available in the jquery-ui-rails gem?

I'm using Ruby 2.0.0, Rails 4.0.3. I'm developing on Windows 8.1 and hosting on Heroku.

Upvotes: 1

Views: 899

Answers (1)

Vince
Vince

Reputation: 4222

The answer is to use jquery-ui-sass-rails It's not redundant. It's designed to work with jquery-ui-rails and uses it as a dependency.

One gotcha I discovered is that I can't have both jquery-ui-rails and jquery-ui-sass-rails in my Gemfile because jquery-ui-sass-rails depends on a specific version of jquery-ui-rails and there could be a version mismatch. I just need to put jquery-ui-sass-rails into Gemfile and it pulls in the correct version of jquery-ui-rails as a dependency.

This is in the Readme for jquery-ui-sass-rails, which I didn't read closely enough.

Upvotes: 1

Related Questions