Heroku不显示SCSS背景图片 [英] Heroku Not Showing SCSS Background Images
问题描述
我有一个Rails应用程序使用来自 style.css.scss
文件的背景图片。我发现有多种方法让图像显示在 localhost
,但没有办法让他们在Heroku上显示。
我已经看过SO的MANY讯息,例如
在Heroku中:
看看你的路径..它必须是你的配置的东西。你有绝对的路径在代码中的某个地方,无论是或者它正在相关的东西。搜索您的代码库,并确保您没有在任何地方硬编码您自己的机器的绝对路径。确保它是相对的。 / Users / elizabethbayardelle / Dropbox / Code / BIA /
不应该在你的源,而是在你的herokuapp实例中使用的某个地方。在你的localhost屏幕截图你甚至有一条路径 heroku.com
...怎么样?第二个接管你如何配置的东西将解决这个我确定。
I have a Rails app that uses background images from a style.css.scss
file. I have found multiple ways of having the images show up on localhost
, but no ways to get them to display on Heroku.
I have looked at MANY posts on SO like this and this, as well as other sites like this, but nothing has worked so far.
Here is the code I have in my style.css.scss
:
.hero-000 {
width: 102%;
background: url(asset-path("hero-000.jpg")) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
However, I have also tried background-image
, image-url
, asset-url
, and numerous other permutations as found in the linked SO posts.
I have this in my production.rb
file:
config.serve_static_files = true
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
config.assets.compile = true
config.assets.digest = true
And this in my application.html.erb
file to call the css sheet:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
As suggested by other posts, I have added this to my application.rb:
config.assets.initialize_on_precompile = false
Any ideas on how this can be resolved would be happily received!
ADDITIONAL INFO
Here's my gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.5'
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development do
gem 'sqlite3'
gem 'binding_of_caller'
gem 'better_errors'
end
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'bcrypt', '~> 3.1.7'
gem 'bootstrap-sass'
gem 'friendly_id', '~> 5.1.0'
gem 'google-analytics-rails', '1.1.0'
gem 'paperclip'
gem 'meta-tags'
gem 'bootsy'
gem 'devise'
Here are my console errors in localhost:
And in Heroku:
Look at your paths.. It must be something with your configuration. You've got your absolute path in code somewhere, either that or it's on track to something related. Search your code-base and make sure you don't have your own machine's absolute path hard-coded anywhere. Make sure it is all relative. /Users/elizabethbayardelle/Dropbox/Code/BIA/
should not be anywhere in your source, but somewhere it is being used in your herokuapp instance. On your localhost screenshot you've even got a path to heroku.com
... how? A second take over how you've configured things will fix this I'm sure.
这篇关于Heroku不显示SCSS背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!