关于 rake 资产的困惑:在 rails 中的资产管道上清理/清理 [英] Confusion about rake assets:clean / cleanup on the asset pipeline in rails

查看:10
本文介绍了关于 rake 资产的困惑:在 rails 中的资产管道上清理/清理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释命令 rake assets:clean 的真正作用吗?不幸的是,Rails 指南没有提到它.还有命令 rake assets:cleanup.有什么区别?

Could somebody explain to me what the command rake assets:clean really does? Unfortunately the Rails Guides dont mention it. There is also the command rake assets:cleanup. Whats the difference?

此外,有人可以告诉我什么时候必须在生产中运行 rake assets:precompile.将所有应用程序文件部署到生产服务器后,是否在服务器控制台上运行它?还是我在本地机器上预编译,然后部署所有文件?

Furthermore could somebody tell me when do I have to run rake assets:precompile in production. Do I run it on the server console after I deployed all my application files to my production server? Or do I precompile on my local machine and then do a deploy of all files?

谢谢大家

推荐答案

注意:这个答案是特定于 rails 3 的.对于 rails 4 及更高版本,请在此处查看其他答案.

如果您在本地机器上预编译,那么您可以将这些生成的资产提交到存储库中并继续部署.无需在生产机器上编译它们.

Note: This answer is rails 3 specific. For rails 4 and later, look at other answers here.

If you precompile on your local machine, then you can commit these generated assets into the repository and proceed with deployment. No need to compile them on production machine.

但它引入了一个问题:现在当您更改源文件(coffescript/scss)时,应用程序不会接受更改,因为它将改为提供预编译文件.rake assets:clean 删除这些预编译的文件.

But it introduces a problem: now when you change source files (coffescript / scss), the app won't pick up the changes, because it will serve precompiled files instead. rake assets:clean deletes these precompiled files.

在我的项目中,资产被预编译为部署的一部分.Capistrano 让这一切变得非常简单.

In my projects assets are precompiled as a part of deployment. Capistrano makes it very easy.

此外,我从未听说过rake assets:cleanup.

这篇关于关于 rake 资产的困惑:在 rails 中的资产管道上清理/清理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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