2

After review, this question has been asked many, many, many times. Yet I still don't grok why rake assets:precompile fails.

I can view the following results from my browser using local server (e.g. thin):

body{
@include background-image(image-url('my_image.png'));
background-repeat: repeat;
    ...
    ...
}

(NOTE: image-path doesn't seem to work at all and I'm using thoughtbot bourbon as SCSS lib)

Yet every time I run precompile I get the following (short trace):

rake aborted!
images/my_image.png isn't precompiled
(in /path/to/myapp/app/assets/stylesheets/application.css.scss)

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

This post suggests that I change my production.rb file, which I did and it compiled my image and rake now complains that I have an undefined mixin 'border-radius'. Perhaps this was the next exception, but I am not so sure. And everything works locally.

Rails Guides (3.1.3) explicitly states setting the value to true

'uses more memory, performs poorer than the default and is not recommended'

So now I have two problems. Performance downgrade and my SCSS library now has undefined mixins.

I would like to solve the production deployment issue resulting from rake assets:precompile. My Gemfile asset group looks like this:

group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
  gem 'zurb-foundation'
  gem 'bourbon' 
 end
Community
  • 1
  • 1
rhodee
  • 1,257
  • 1
  • 14
  • 27

2 Answers2

2

If you go with the assets:precompile option, you should use @import statements in every stylesheet you use a mixin.

e.g.

Let's say you have a custom mixin in app/assets/stylesheets/partials/_mixins.css.scss that you use in a stylesheet, you should add

@import "partials/mixins";

to that stylesheet.

I know, is shouldn't be like that, but as for now, I haven't found any other way.

joiggama
  • 1,632
  • 1
  • 10
  • 8
0

The image-path helper assumes the images part of the path so remove that (and the slash) and it should start working.

Richard Hulse
  • 10,383
  • 2
  • 33
  • 37
  • `image-url('file_name.png')` nor `image-path('file_name.png')` provide the desired result (asset precompilation) – rhodee Dec 09 '11 at 17:09
  • where it he file actually located (from app down) – Richard Hulse Dec 09 '11 at 18:58
  • Precompile does bail at the first error. The fact that you get an undefined mixin suggests that something else is amis, but I can't for the life of me work it out. When you precompile (prior to it crashing) do you see the fingerprinted image files appear in public/assets ? – Richard Hulse Dec 10 '11 at 05:20
  • The image is fingerprinted in pub/assets. this is very frustrating. – rhodee Dec 10 '11 at 06:49
  • You could try adding .erb to the file, and temporarily using the asset_path helper to see if you get any more errors (clues). – Richard Hulse Dec 10 '11 at 07:07
  • that did not do anything either. perhaps this is a sass-rails issue. – rhodee Dec 10 '11 at 16:48