Search code examples
ruby-on-railsdokkubuildpack

Dokku deployed Rails site does not rewrite SCSS images


I'm using Dokku to deploy a RoR site, using the Herokuish Ruby buildpack.

There are no errors when I deploy: (though the time does seem quite short)

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       Asset precompilation completed (3.58s)
       Cleaning assets

The asset filenames are being fingerprinted correctly and the images used in the views having their paths rewritten as expected.

However, despite the fact that I'm using background-image: url(image_path('parallax/masthead.jpg')); in the SCSS, the URLs are not being rewritten.

Here are the relevant lines from my config/production.rb

config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true

In my Gemfile I have:

group :production do
  gem 'puma', '~> 2.15.3'
  gem 'rails_12factor'
end

I tried running rake assets:precompile RAILS_ENV=production locally and it worked, with both the views and CSS being rewritten correctly.


Solution

  • Ah I've found it - in the SCSS file I had:

    background: url(image_path('layout/opacity.png')) repeat; 
    

    which for some reason was causing it to fail. Changing it to:

    background-image: url(image_path('layout/opacity.png'));
    background-repeat: repeat;
    

    sorted it.