[英]rake assets:precompile not working on heroku
我的網站曾經在工作,Heroku預編譯了資產和一切。 現在,似乎無處不在,我開始讓rake aborted! stack level too deep
rake aborted! stack level too deep
在部署時rake aborted! stack level too deep
。
刪除行*= require_tree .
從我的application.css文件似乎修復stack level too deep
但后來我得到這個:
Running: rake assets:precompile
(in /tmp/build_b8o2t4k8frce)
/usr/local/bin/ruby /tmp/build_b8o2t4k8frce/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
(in /tmp/build_b8o2t4k8frce)
我所有的圖像鏈接都被破壞了(我在我的css文件中使用了image-url())。 可能是什么問題,我該如何解決?
我正在使用雪松堆棧,這是我的gemfile:
gem 'rails', '3.1.0'
gem 'rake', '0.8.7'
gem 'devise'
group :production do
gem 'pg'
gem 'thin'
end
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
以下是heroku使用的版本:
Using rake (0.8.7)
Using rails (3.1.0)
Using sass (3.1.15)
Using sass-rails (3.1.6)
這是我的application.rb文件
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module App
class Application < Rails::Application
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
end
end
這是我的production.rb文件
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rails's static asset server (Apache or nginx will not need this)
config.serve_static_assets = true
# Set expire header of 30 days for static files
config.static_cache_control = "public, max-age=2592000"
# Allow JavaScript and CSS compression
config.assets.compress = true
# Compress JavaScript by removing whitespace, shortening variable names, ...
config.assets.js_compressor = :uglifier
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
我遇到了類似的問題,並在此處找到答案: https : //github.com/rails/sass-rails/issues/78 。 基本上,降級到sass-rails v3.1.4。 希望這可以幫助
您不應該刪除此*= require tree .
來自application.css,因為它加載你所有的樣式。 只需添加它,並配置您的config/production.rb
文件,如下所示:
config.assets.precompile = %w{application.js}
並運行RAILS_ENV =生產佣金資產:預編譯
編輯嘗試使用此配置:
config.assets.digest = true
顯然sass停止了工作,我沒有耐心,所以我決定不再使用它了。 而不是這樣做:
#theme.css.scss
background-image:image-url('image.png');
現在我只是使用erb文件:
#theme.css.erb
background-image:url(<%= asset_path 'image.png' %>);
我因此失去了一整天,我不知道為什么因為它昨天工作正常。 如果有人知道是什么導致了這個以及如何再次使用sass,請發表評論。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.