Heroku资产预编译 [英] Heroku Assets Precompile

查看:128
本文介绍了Heroku资产预编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我正在使用我在Heroku上运行了几个月的应用程序,试图让我的开发环境中运行一些东西:

Today I was working with an application I've had running on Heroku for a few months now and in an attempt to get something working I ran in my development environment:

rake assets:precompile

推送到Heroku,我的请求中有500个错误:

When I committed my changes and pushed to Heroku, I get 500 errors on my request:

ActionView::Template::Error (jquery.flexslider-min.js isn't precompiled):

我该做些什么,我已经尝试了几件事情:

I'm at a bit of a loss as to what to do, I've tried a few things:

懒惰地编译生产(我真的不想这样做):

Lazily compile in production (which I really don't want to do):

Bundler.require(:default, :assets, Rails.env)

具体列出所有需要预编译的文件(也不是真的想这样做,看起来效率不高):

Specifically list all of the files that need to be "precompiled" (also don't really want to do this, doesn't seem very efficient):

config.assets.precompile += ...



<到目前为止,我只是做了一个rollbac k到我最后的工作版本。我目前无法推送新代码。将会建立一个临时环境(就像我早就应该做的那样),但不知道下一步该做什么或者什么可以解决这个问题?为什么不在这之前抛出错误?

So far I've simply done a rollback to my last working version. I'm currently stuck unable to push new code. Will be setting up a staging environment (like I should've done long ago) but not sure what to do next or what might fix this issue? Why didn't this throw an error before?

rake assets:clean

似乎解决了这个问题,但我不明白为什么。有人可以分享一些有关这方面的见解吗?

Appears to have resolved the problem, although I don't understand why. Can someone share some insight into this?

推荐答案

我愿意在manifest.yml中下注编译的版本/文件名public / assets文件夹已过期/错误。

I'm willing to bet a compiled version/filename inside of manifest.yml in the public/assets folder was out of date/wrong.

如果您对flexslider.js文件进行了更改,则需要使用 rake assets:预编译并将更新后的版本推送到github。我相信你可以在manifest.yml文件中设置资产的版本。

If you've made changes to the flexslider.js file, you'll need to recompile with rake assets:precompile and push the updated version to github. I believe you can set the version of the assets inside of the manifest.yml file.

另外,我相信你可以运行 heroku运行rake资产:clean heroku run rake assets:precompile

Also, I believe you can run heroku run rake assets:clean or heroku run rake assets:precompile.

我不认为由于版本控制和名称冲突/未存储在github中,预先编译heroku内的资源是一个好主意。

I don't think it would be a good idea to precompile assets inside of heroku because of versioning and name conflicts/not stored in github.

您可以清理heroku中的资产并再次推送回购,因此您不需要在本地进行预编译并将其推送到github,除非其中存在真正的问题本地编译。

You can clean the assets in heroku and push the repo again, so you wouldn't need to precompile locally and push to github, unless there was indeed an issue in the local compilation.

我也花了几分钟时间阅读 http://guides.rubyonrails.org/asset_pipeline.html

I'd also take a few minutes to read http://guides.rubyonrails.org/asset_pipeline.html

另一种可能性是您的文件名称存在链接问题。为什么不使用flexslider.js的开发版本,将其重命名为稍微方便一些,并允许链轮进行缩小。

Another possibility is your file name is having issues with sprockets. Why not use the development version of the flexslider.js, rename it to something slightly more convenient, and allow sprockets to do the minification.

这篇关于Heroku资产预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆