耙资产:预编译不能在heroku上工作 [英] rake assets:precompile not working on heroku
问题描述
rake!堆栈级别太深
部署。 删除行 * = require_tree。
from我的application.css文件似乎修复了堆栈层太深
,但是我得到这个:
运行:rake资产:预编译
(in / tmp / build_b8o2t4k8frce)
/ usr / local / bin / ruby /tmp/build_b8o2t4k8frce/vendor/bundle/ruby/1.9.1/ bin / rake资源:预编译:nondigest RAILS_ENV = production RAILS_GROUPS =资产
(in / tmp / build_b8o2t4k8frce)
我所有的图像链接都被打破了(我在我的css文件中使用了image-url())。可能是这个问题,我该如何解决它?
我使用雪松堆栈,这是我的gemfile:
gem'rails','3.1.0'
gem'rake','0.8.7'
gem'devise'
组:生产do
gem'pg'
gem'瘦'
结束
组:资产do
gem'sass-rails' ,〜> 3.1.0
gem'coffee-rails',〜> 3.1.0
gem'uglifier'
end
$ c $ 使用rake(0.8.7)
使用rails(3.1.0)
使用sass(3.1.15)
使用sass-rails(3.1.6)
这是我的application.rb文件
if defined?(Bundler)
#如果您在部署到产品之前预编译资产,请使用以下命令:
Bundler.require * Rails.groups(:assets =>%w(开发测试) )
#如果你希望你的资产在生产中被懒惰地编译,使用thi s行
#Bundler.require(:default,:assets,Rails.env)
结尾
模块App
class Application< Rails :: Application
#启用资产管道
config.assets.enabled = true
#您的资产版本,如果您想过期你的资产。
config.assets.version ='1.0'
end
end
这里是我的production.rb文件
#完全错误报告被禁用,缓存打开
config。考虑_all_requests_local = false
config.action_controller.perform_caching = true
#启用Rails的静态资产服务器(Apache或nginx不需要这样)
config.serve_static_assets = true
#为静态文件设置30天的过期标题
config.static_cache_control =public,max-age = 2592000
#允许JavaScript和CSS压缩
config .assets.compress = true
#通过删除空格,缩短变量名称来压缩JavaScript
config.assets.js_compressor =:uglifier
#Don如果预编译的资产错过了,则回退到资产管道
config.assets.compile = true
#为资产URL生成摘要
config.assets.digest = true
解决方案我有类似的问题,并在这里找到答案: https://github.com/rails/sass-rails/issues/78 。基本上,降级到sass-rails v3.1.4。希望这有助于
My website used to be working and Heroku precompiled the assets and everything. Now, seemingly out of nowhere, I started to get rake aborted! stack level too deep
on deploy.
Deleting the line *= require_tree .
from my application.css file seems to fix thestack level too deep
but then I get this:
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)
All my links to images are broken (I'm using image-url() in my css file). What could be the problem and how do I fix it?
I'm using cedar stack and this is my 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
And here are the versions used by heroku:
Using rake (0.8.7)
Using rails (3.1.0)
Using sass (3.1.15)
Using sass-rails (3.1.6)
Here's my application.rb file
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
And here's my production.rb file
# 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
解决方案 I had a similar problem and found the answer here: https://github.com/rails/sass-rails/issues/78. Basically, downgrade to sass-rails v3.1.4. Hope this helps
这篇关于耙资产:预编译不能在heroku上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!