关于rake资产的混淆:在rails中的资产管道上进行清理/清理 [英] Confusion about rake assets:clean / cleanup on the asset pipeline in 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
.将所有应用程序文件部署到生产服务器后,是否可以在服务器控制台上运行它?还是我在本地计算机上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屋!