Frage

On localhost, Compass works perfectly. screen.scss loads compass/reset just fine. So does print.scss.

On Heroku, screen.scss still works, but print.scss gives this error:

Error compiling CSS asset
Sass::SyntaxError: File to import not found or unreadable: compass/reset.
Load path: Sass::Rails::Importer(/app/app/assets/stylesheets/print.scss)
(in /app/app/assets/stylesheets/print.scss)
/app/app/assets/stylesheets/print.scss:1

Why? How do I fix it?

Relevant lines from relevant files...

Gemfile:

gem "compass"
gem "pg"
gem "sass"
gem "sass-rails"
gem "haml"
gem "haml-rails"
gem "susy"
# gem "thin"
gem "unicorn"
gem "pdfkit"
gem "wkhtmltopdf-binary"

group :assets do
  gem "sass-rails"
  gem "coffee-rails"
  gem "compass-rails"
  gem "compass-susy-plugin"
end

config/application.rb:

if defined?(Bundler)
  Bundler.require *Rails.groups(:assets => %w(development test))
end

module Testivate
  class Application < Rails::Application
    config.assets.enabled = true
    config.assets.paths << "#{Rails.root}/app/assets/fonts"    
    config.assets.initialize_on_precompile = false
    config.assets.version = '1.0'
    config.middleware.use "PDFKit::Middleware", :print_media_type => true        
  end
end

/config/environments/production.rb:

Testivate::Application.configure do
  config.cache_classes = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = true
  config.assets.precompile += %w( .svg .eot .woff .ttf )
  config.assets.compress = true
  config.assets.compile = true
  config.assets.digest = true
end

/app/assets/stylsheets/screen.scss (first line):

@import "compass/reset";

/app/assets/stylesheets/print.scss (first line):

@import "compass/reset";

/app/assets/stylesheets/application.css:

/*
 *= require_self
 *= require jquery.ui.core
 *= require screen
*/

/app/views/reviews/print.html (as compiled from print.html.haml):

<head>
<link href="/assets/print.css" media="print, screen, projection" rel="stylesheet" type="text/css" />
</head>

/app/views/reviews/show.html (as compiled from show.html.haml):

<head>
<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css" />
</head>
War es hilfreich?

Lösung

Found the answer on the 55 Minutes blog:

By default, Rails only precompiles application.css. If you have additional stylesheets, like perhaps ie.css or print.css, these won’t be precompiled unless you explicitly tell Rails to do so.

config.assets.precompile += ['ie.css', 'print.css']

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top