0

在 localhost 上,Compass 运行良好。screen.scss加载compass/reset就好了。也是如此print.scss

在 Heroku 上,screen.scss 仍然有效,但print.scss出现此错误:

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

为什么?我如何解决它?

相关文件中的相关行...

宝石文件

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

配置/应用程序.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(第一行):

@import "compass/reset";

/app/assets/stylesheets/print.scss(第一行):

@import "compass/reset";

/app/assets/stylesheets/application.css

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

/app/views/reviews/print.html(编译自print.html.haml):

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

/app/views/reviews/show.html(编译自show.html.haml):

<head>
<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css" />
</head>
4

1 回答 1

0

在55 分钟博客上找到了答案:

默认情况下,Rails 只预编译 application.css。如果你有额外的样式表,比如 ie.css 或 print.css,除非你明确告诉 Rails 这样做,否则它们不会被预编译。

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

于 2013-03-14T05:32:29.623 回答