Skip to content

Instantly share code, notes, and snippets.

@ilake
Created December 5, 2012 00:13
Show Gist options
  • Select an option

  • Save ilake/4210583 to your computer and use it in GitHub Desktop.

Select an option

Save ilake/4210583 to your computer and use it in GitHub Desktop.
assets pipeline
# For sprockets-2.1.3
# in lib/sprockets/asset.rb
# Asset class, initialize method
# just use path
@digest = environment.file_digest(pathname).hexdigest
puts "========== Assets::initialize:pathname #{pathname}"
puts "========== Assets::initialize:@digest #{@digest}"
# in lib/sprockets/processed_asset.rb
# ProcessedAsset < Asset, initialize method
# the source over here is the content be processed (like .coffee, scss), if it need processed
# , it will also do some compressed(remove space etc...)
# will execute processor(syntax process, check?) and compress here
@digest = environment.digest.update(source).hexdigest
puts "========= ProcessedAsset::initialize:source #{source}"
puts "========= ProcessedAsset::initialize:@digest #{@digest}"
# in lib/sprockets/bundled_asset.rb
# the source before
# BundledAsset < Asset, initialize method
# the source over here is the content be compressed
@digest = environment.digest.update(source).hexdigest
puts "SP========= BundledAsset::initialize:source #{source}"
puts "SP========= BundledAsset::initialize:@digest #{@digest}"
# So like pure .js or .css it don't need processed in ProcessedAsset, then it will be compressed
# in BundleAsset, then this two @digest in ProcessedAsset and BundledAsset will be different
# but if it need to be processed, then the two @digest will be the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment