【问题标题】:Why won't print.scss load compass/reset on Heroku?为什么 print.scss 不能在 Heroku 上加载指南针/重置?
【发布时间】:2013-03-13 10:55:15
【问题描述】:

在 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

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(第一行):

@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>

【问题讨论】:

  • 在部署到 Heroku 之前,您没有在本地预编译资产是否有原因?
  • 因为 (a) 不预编译似乎没有给我带来任何问题,并且 (b) 预编译将一堆预编译的资产放在 /public/ 中,这与 /asset/ 中的资产发生冲突我在 localhost 上查看了我的应用程序。您认为这可能是问题所在吗?

标签: ruby-on-rails asset-pipeline compass-geolocation


【解决方案1】:

55 Minutes博客上找到答案:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-06
    • 2012-01-10
    相关资源
    最近更新 更多