引入JavaScrpit/CSS |
manifesto |
n. 货单 |
默认的manifesto的位置 |
/app/assets/javascripts/application.js
/app/assets/stylesheets/application.css |
manifest可用的方法 |
形式: 在comment(, //)内用=来开头
例子:
//= require_self
include指定的path |
require path |
按字母顺序include指定文件夹内的文件 |
require_directory path |
按递归(?)顺序include指定文件夹内的文件 |
require_tree path |
把当前文件内的内容插入到其他require的前面 |
require_self |
|
|
确认默认库的位置 |
rails c
irb(main):001:0> puts
Rails.application.config.assets.paths |
|
|
|
|
|
|
|
|
|
引用JavaScrpit, CSS
通过manifest |
前提 |
已经声明了manifest |
方法 |
stylesheet_link_tag(src [,opts]) |
参数 |
src |
manifest的文件名
去掉后缀 |
opt |
选项(书上没有) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Asset
Pipeline |
Asset Pipeline流程 |
,CSS等源代码 |
1.编译每一个文件 ---》
2.整合到application ---》
3.压缩(删掉comment,换行) ---》
4.增加digest(哈希值?) |
|
|
图片,音频,视频等纯资源 |
增加digest(哈希值?) |
|
|
注意 |
development环境下
2.整合到application ---》
3.压缩(删掉comment,换行) ---》
不执行 |
|
|
|
|
|
|
|
|
|
|
|
设定 |
位置 |
config/enviroments/development.rb等 |
设定项 |
含义 |
参数 |
默认值 |
development |
production |
asset的位置 |
config.assets.path |
自定义的都在app/assets/里面
默认的参照【确认默认库的位置】 |
路径的前缀 |
config.assets.prefix |
/assets |
/assets |
debug模式
(是否整合资源源代码) |
config.assets.debug |
true |
false |
是否自定编译 |
config.assets.compile |
true |
false |
是否追加digest |
config.assets.digest |
true |
true |
JavaScript的压缩库 |
config.assets.js_compressor |
nil |
:uglifier |
CSS的压缩库 |
config.assets.css_compressor |
nil |
:sass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CoffeeScript |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sass(SCSS) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ajax开发 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Turbolinks |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|