资产管道/预编译资产任务
如何使 rake 任务
assets:precompile
在我的 Rails 2.3.14 应用程序中可用?
How I can make the rake task
assets:precompile
available into my rails 2.3.14 app ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在寻找 asset:precompile rake 任务的源代码,您可以在这里找到它:
https://github.com/rails/rails/blob/3-1-stable/actionpack/lib/sprockets/assets.rake
当您使用链轮和链轮助手 gem 将其复制到 Rails 2.3.14 应用程序中的 lib/tasks 时,不要指望它能按原样运行。
[更新]
我制作了一个简单的预编译器rake任务,用于rails 2.3.14(没有任何javascript压缩)。您可能想要更改一些内容,具体取决于您的配置。仔细测试清理任务,因为它使用 rm_rf 命令;-)
[更新 #2]
我现在正在使用这种方法,并且效果很好:
http://jaredonline. github.io/blog/2012/05/16/sprockets-2-with-rails-2-dot-3/
If you are looking for the source code of the assets:precompile rake task, you can find it here:
https://github.com/rails/rails/blob/3-1-stable/actionpack/lib/sprockets/assets.rake
Don't expect it to run as-is when you copy it to your lib/tasks in your rails 2.3.14 app with the sprockets and sprockets-helpers gems.
[update]
I made a simple precompiler rake task for use in rails 2.3.14 (without any javascript compression). You might want to change some things, depending on your configuration. Test the clean up task carefully, because it use a rm_rf command ;-)
[update #2]
I am now using this approach, and that works fine:
http://jaredonline.github.io/blog/2012/05/16/sprockets-2-with-rails-2-dot-3/
没有一个简单的方法。资产管道依赖于 Rails 3.1.x 中的多个架构,而 Rails 2.3 中不存在这些架构。
您可以尝试使用戴维斯·弗兰克 (Davis Frank) 在此概述了,但请注意,这需要执行许多步骤。
There isn't a straightforward approach. The asset pipeline relies on several pieces of architecture in Rails 3.1.x that aren't present in Rails 2.3.
You can try using the approach that Davis Frank outlines here, but be warned that it requires a number of steps.