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

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

问题描述

命令rake assets: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

我刚刚编写了一个 gem 来解决这个问题,名为 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 gem,那就太棒了,让如果您有任何问题,我知道.

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天全站免登陆