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

Client-Side Development with Brunch

Avatar for janmonschke janmonschke
February 17, 2012

Client-Side Development with Brunch

This talk was held at BerlinJS on February 16th 2012.

Avatar for janmonschke

janmonschke

February 17, 2012
Tweet

More Decks by janmonschke

Other Decks in Programming

Transcript

  1. Client-­‐Side  development  with  Brunch  –  BerlinJS   •  Lightweight  library

     to  help  structuring  your  code   •  MVC-­‐ish  principles   •  Works  out-­‐of-­‐the-­‐box  with  all  REST-­‐backends  *   •  Backbone.js  +  CoffeeScript  =  <3     •  Great  community  (support  &  plug-­‐ins)  
  2. Client-­‐Side  development  with  Brunch  –  BerlinJS   •  Examples  are

     mostly  wricen  in  single  files  -­‐>  does  NOT  work   for  complex  applica@ons   •  You  need  to  setup  your  own  directory  structure     <script  src="src/models/unicorn.js"></script>   <script  src="src/models/user.js"></script>   <script  src="src/controllers/user_controller.js"></script>   <script  src="src/controllers/main_controller.js"></script>   <script  src="src/views/user.js"></script>       <script  src="src/views/user_list.js"></script>   <script  src="src/main.js"></script>   (...)   (...)  
  3. Client-­‐Side  development  with  Brunch  –  BerlinJS   •  Templates  in

     index.html,  srsly?       <script  type="text/template"  id="stats-­‐template">              <%  if  (total)  {  %>                  <span  class="todo-­‐count">                      <span  class="number"><%=  remaining  %></span>                      <span  class="word"><%=  remaining  ==  1  ?  'item'  :  'items'  %></span>  le8.                  </span>              <%  }  %>              <%  if  (done)  {  %>                  <span  class="todo-­‐clear">                      <a  href="#">                          Clear  <span  class="number-­‐done"><%=  done  %></span>                          completed  <span  class="word-­‐done"><%=  done  ==  1  ?  'item'  :  'items'  %></span>                      </a>                  </span>              <%  }  %>          </script>  
  4. Brunch Client-­‐Side  development  with  Brunch  –  BerlinJS   •  (pre-­‐)Compiles

     all  files  (Code  +  Templates  +  Styles)   •  Assembles  them  into  one  single  file   •  Watches  for  file-­‐changes   •  Provides  a  proven  directory  structure   •  But  works  with  any   •  Powerful  plug-­‐in  system  
  5. npm  install  –g  [email protected]:brunch/brunch.git     brunch  new  <project-­‐name>  

      brunch  build     brunch  watch  (-­‐-­‐server)   Client-­‐Side  development  with  Brunch  –  BerlinJS   Brunch
  6. Client-­‐Side  development  with  Brunch  –  BerlinJS   Brunch Clean  directory

     structure     /brunch  does  not  get  in  the  way     config.coffee  –  plugin-­‐ins,  vendor-­‐files    
  7. Client-­‐Side  development  with  Brunch  –  BerlinJS   Brunch Let‘s  dive

     into  some  code!   hcp://brunch-­‐colors.com  
  8. Client-­‐Side  development  with  Brunch  –  BerlinJS   Brunch I  probably

     forgot  a  ton  of  things  ;)       Find  more  info  on  hcp://brunch.io