Capistrano有自己的内置任务"部署/assets资源 ".它会自动为您完成任务.
您自己的手工任务之间的区别在于,它只加载assets
组预编译assets资源 ,而不是整个环境.
cd /home/apps/APP_NAME/releases/20120708184757 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile
https://gist.github.com/3072362
如果
如果发生更改,它将重新编译assets资源 .否则,它将跳过pecompile过程,节省大量时间.
@import "compass";
directly.当你
在SCSS中为@import "compass";
或@import "compass/typography/links/link-colors";
.
但在编译assets资源 时,@import "compass/typography/links/link-colors";
比@import "compass";
快9倍.
这是因为当@import "compass";
时,它会编译整个指南针assets资源 .不仅仅是link-colors
部分.
在SCS中,我们喜欢使用partial
来组织我们的assets资源 .
但只有当你需要共享变量,或者有必要的依赖关系,否则
//= require "reset"
//= require "base"
//= require "product"
比
@import "reset";
@import "base";
@import "product";
当我们使用Rails生成器生成控制器时.Rails还将生成这样的assets资源
并在应用程序中装载assets资源 .js使用以下技术:
//= require_tree
但是空assets资源 (不输出)只包含以下行:
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
It will cost you about 250ms to compile each of them. 如果 you have 10 empty assets, it will be 2.5 seconds .
从项目中删除它们,或在应用程序中单独装载它们.像这样:
//= require prodcuts
//= require users
//= require albums
css.scss
or js.coffee
if unnecessary.custom.css
等于custom.css.scss
编译纯CSS和纯JS的速度很快(几乎需要0毫秒).但是编译.scss和.咖啡仍然需要一些时间.
判断日志(log)/生产记录.日志(log)