耙式资产:预编译缓慢 [英] rake assets:precompile is slow

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

问题描述

命令"rake asset:precompile"对我来说非常慢.特别是在我的Amazon EC2 Micro生产服务器上,该服务器没有很多处理器资源.在EC2上,每次部署过程中我都必须等待1分钟或更长时间,仅用于此预编译任务.有没有办法使其更快?

The command "rake assets:precompile" works very slow for me. Especially on my Amazon EC2 Micro production server which does not have a lot of processor resources. On EC2 I have to wait 1 minute or more during each deployment just for this precompile task alone. Is there a way to make it faster?

以前,我使用Jammit压缩/最小化CSS和JS. Jammit在相同的网站和服务器上的工作速度快了将近10倍.

Previously I used Jammit to compress/minify css and js. Jammit worked nearly 10 times faster on the same web site and servers.

推荐答案

如果您不需要加载Rails环境,则应使用以下命令禁用它:

If you don't need to load the Rails environment, you should disable that with:

config.assets.initialize_on_precompile = false

我刚刚写了一个宝石来解决这个问题,叫做 turbo-sprockets-rails3 .仅重新编译更改的文件,并且仅编译一次即可生成所有资产,从而加快了assets:precompile的速度.

I've just written a gem to solve this problem, called turbo-sprockets-rails3. It speeds up your assets:precompile by only recompiling changed files, and only compiling once to generate all assets.

如果您能帮助我测试 turbo-sprockets-rails3 宝石,那真是太棒了,我知道您是否有任何问题.

It would be awesome if you could help me test out the turbo-sprockets-rails3 gem, and let me know if you have any problems.

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

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