Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Desmistificando o Asset Pipeline

Rondy Sousa
September 15, 2012

Desmistificando o Asset Pipeline

Rondy Sousa

September 15, 2012
Tweet

More Decks by Rondy Sousa

Other Decks in Programming

Transcript

  1. "If a problem is very commom, we end up with

    a proliferation of choices." :FIVEB,BU[ Saturday, September 15, 12
  2. a linear sequence of specialized modules which performs a task,

    like an assembly line in a factory. pipe.line noun Saturday, September 15, 12
  3. "We're elevating this stuff up to the same importance as

    Ruby code itself." %BWJE))BOTTPO3BDF$BS%SJWFS Saturday, September 15, 12
  4. (FNpMF group :assets do gem 'sass-rails', '~> 3.2.3' # gem

    'therubyracer', :platforms => :ruby gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end Saturday, September 15, 12
  5. <head> <title>Rs on Rails</title> <%= stylesheet_link_tag "application", media: "all" %>

    <%= javascript_include_tag "application" %> <%= csrf_meta_tags %> </head> BQQWJFXTMBZPVUTBQQMJDBUJPOIUNMFSC Saturday, September 15, 12
  6. /* *= require_self *= require reset *= require layout *=

    require sidebar *= require navigation *= require typography *= require forms *= require colors */ BQQWJFXTMBZPVUTBQQMJDBUJPODTT Saturday, September 15, 12
  7. /* *= require_self *= require reset *= require layout *=

    require sidebar *= require navigation *= require typography *= require forms *= require colors */ BQQWJFXTMBZPVUTBQQMJDBUJPODTT no jargão, o “manifesto” Saturday, September 15, 12
  8. DPOpHFOWJSPONFOUTEFWFMPQNFOUSC RsOnRails::Application.configure do config.assets.compress = false config.assets.debug = true end

    RsOnRails::Application.configure do config.assets.compress = true config.assets.compile = false config.assets.digest = true end DPOpHFOWJSPONFOUTQSPEVDUJPOSC Saturday, September 15, 12
  9. require 'sprockets' map '/assets' do environment = Sprockets::Environment.new environment.append_path 'app/assets/javascripts'

    environment.append_path 'app/assets/stylesheets' run environment end map '/' do run YourRackApp end Saturday, September 15, 12
  10. (FNpMF group :assets do gem 'sass-rails', '~> 3.2.3' # gem

    'therubyracer', :platforms => :ruby gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end Saturday, September 15, 12
  11. /* *= require common */ body { color: $base-font-color; }

    BQQBTTFUTTUZMFTIFFUTBQQMJDBUJPODTTTDTT $base-font-color: #555555; BQQBTTFUTTUZMFTIFFUTDPNNPODTTTDTT Saturday, September 15, 12
  12. class TimestampProcessor < Sprockets::Processor def evaluate(context, locals) data end end

    MJCQSPDFTTPSTUJNFTUBNQ@QSPDFTTPSSC Saturday, September 15, 12
  13. class TimestampProcessor < Sprockets::Processor def evaluate(context, locals) current_timestamp = DateTime.now.to_s(:timestamp)

    ["/* #{current_timestamp} */", data].join("\n") end end MJCQSPDFTTPSTUJNFTUBNQ@QSPDFTTPSSC Saturday, September 15, 12
  14. var Showdest = { description: "Are you showdest, my friend?"

    } alert(Showdest.description); //= require_self //= require showdest BQQBTTFUTKBWBTDSJQUTTIPXEFTUKT BQQBTTFUTKBWBTDSJQUTBQQMJDBUJPOKT Saturday, September 15, 12
  15. $ bundle gem showdest $ cd showdest $ mkdir -p

    vendor/assets/javascript Saturday, September 15, 12
  16. $ bundle gem showdest $ cd showdest $ mkdir -p

    vendor/assets/javascript $ mv ~/code/rs-on-rails/app/assets/javascripts/showdest.js \ vendor/assets/javascript Saturday, September 15, 12
  17. module Showdest class Engine < Rails::Engine end end TIPXEFTUMJCTIPXEFTUFOHJOFSC Gem::Specification.new

    do |gem| gem.add_dependency "railties", ">= 3.1", "< 5.0" end TIPXEFTUTIPXEFTUHFNTQFD Saturday, September 15, 12