Jason Stokes
Jason Stokes

Reputation: 707

Rails: How do you precompile custom stylesheet for production environment?

I've tried numerous fixes and variations of those fixes that I've found online but none work. My problem is that I have a custom stylesheet that is called if the browser is IE (stylesheet-ie.css.scss). I've ran the following with no success:

rake assets:precompile

I get the following error in production.log after running compile command.

ActionView::Template::Error (stylesheet-ie.css isn't precompiled):
    14:     <title><%= full_title(yield(:title)) %></title>
    15:     <%= stylesheet_link_tag    "application", media: "all" %>
    16:     <!--[if IE]>
    17:       <%= stylesheet_link_tag("stylesheet-ie") %>
    18:     <![endif]-->
    19:     <%= javascript_include_tag "application" %>
    20:     <%= csrf_meta_tags %>

In production.rb I have:

config.assets.precompile += ['stylesheet-ie.css']

The file is assets/stylesheet/stylesheet-ie.css.scss...I had it as stylesheet.css before but changed it trying to get it to work. Neither way works.

At this point I don't know what else to do.

Upvotes: 0

Views: 209

Answers (2)

sandeep
sandeep

Reputation: 521

Does this work in development environment?

While doing a precompile, you will have to specify the environment. Are you doing this anywhere?

RAILS_ENV=production rake assets:precompile 

This should compile your assets in case you are not mentioning your environment elsewhere.

Upvotes: 1

rking
rking

Reputation: 1662

Hrm.

I have my config/application.rb set up like this:

config.sass.load_paths << File.expand_path('../../lib/assets/stylesheets/')
config.assets.precompile += %w(jquery.animate-colors-min.js ie.js ie8.css)

So it's pretty similar, but you didn't mention the load_paths. (Also, BTW, I'm using .css.sass, so I'm not sure if you'll need to fiddle with config.sass or config.scss.)

—☈

Upvotes: 0

Related Questions