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

株式会社 Loco Partners の社内開発 LT 2014年11月18

株式会社 Loco Partners の社内開発 LT 2014年11月18

2014年11月18日開催

株式会社 Loco Partners の社内開発 LT で Grunt の超入門について発表

Kenya Yamaguchi

November 18, 2014
Tweet

More Decks by Kenya Yamaguchi

Other Decks in Technology

Transcript

  1. ࠷ۙͷ WEB ΞϓϦ։ൃ AltJS (CoffeeScript, TypeScript) ͷίϯύΠϧ ֦ு CSS (Sass,

    Less, Stylus) ͷίϯύΠϧ JS, CSS ͷ݁߹ͱѹॖ JS, CSS ͷߏจνΣοΫ
  2. ࠷ۙͷ WEB ΞϓϦ։ൃ AltJS (CoffeeScript, TypeScript) ͷίϯύΠϧ ֦ு CSS (Sass,

    Less, Stylus) ͷίϯύΠϧ JS, CSS ͷ݁߹ͱѹॖ JS, CSS ͷߏจνΣοΫ ཁ͢Δʹɺ͜ΕΒΛશ෦ GRUNT ͕ࣗಈͰ΍ͬͯ͘ΕΔʂ
  3. GRUNT ͸͜Μͳʹ؆୯ʹ࢝ΊΕΔʂ (౜ಥʹ࢝·Δ४උखॱ) ࠇ͍ը໘(ίϯιʔϧ)Λ։͍ͯɺ্͔Βॱʹίϐʔ & షΓ ෇͚ ͔Βͷ Enter!!! cd

    ~ && mkdir sandbox && mkdir -p sandbox/assets/css && mkdir sandbox/css touch sandbox/assets/css/part1.css && echo "body { background-color: #F2F2F0; }" > sandbox/assets/css/part1.css touch sandbox/assets/css/part2.css && echo "h1 { font-size: 100%; }" > sandbox/assets/css/part2.css
  4. GRUNT ͸͜Μͳʹ؆୯ʹ࢝ΊΕΔʂ (౜ಥʹ࢝·Δ४උखॱ) ࠇ͍ը໘(ίϯιʔϧ)Λ։͍ͯɺ্͔Βॱʹίϐʔ & షΓ ෇͚ ͔Βͷ Enter!!! cd

    ~ && mkdir sandbox && mkdir -p sandbox/assets/css && mkdir sandbox/css touch sandbox/assets/css/part1.css && echo "body { background-color: #F2F2F0; }" > sandbox/assets/css/part1.css touch sandbox/assets/css/part1.css && echo "h1 { font-size: 100%; }" > sandbox/assets/css/part2.css
  5. GRUNT ͸͜Μͳʹ؆୯ʹ࢝ΊΕΔ (౜ಥʹ࢝·ΔΠϯετʔϧखॱ) cd ~/sandbox ruby -e "$(curl -fsSL https://raw.githubusercontent.com/

    Homebrew/install/master/install)" brew npm install npm install -g grunt-cli npm install grunt-contrib จࣈ͕Ұഋग़ͯ͘Δ͚ͲɺΠϯ ετʔϥʔͰιϑτΛΠϯετʔϧ ͍ͯ͠ΔΑ͏ͳ΋ͷͰ͢ɻ
  6. GRUNT ͸͜Μͳʹ؆୯ʹ࢝ΊΕΔ (౜ಥʹ࢝·ΔΠϯετʔϧखॱ) cd ~/sandbox ruby -e "$(curl -fsSL https://raw.githubusercontent.com/

    Homebrew/install/master/install)" brew npm install npm install -g grunt-cli npm install grunt-contrib จࣈ͕Ұഋग़ͯ͘Δ͚ͲɺΠϯ ετʔϥʔͰιϑτΛΠϯετʔϧ ͍ͯ͠ΔΑ͏ͳ΋ͷͰ͢ɻ
  7. GRUNT ઃఆखॱ (CSS ͷ݁߹) cd ~/sandbox vi Gruntfile.js module.exports =

    function(grunt) { grunt.initConfig({ cssmin: { compress: { files: { 'css/kansei.css': [ 'assets/css/part1.css', 'assets/css/part2.css' ] } } } }); grunt.loadNpmTasks('grunt-contrib-cssmin'); }; ϑΝΠϧͷதʹ ͍ͭ͜Λॻ͖ࠐΜͰอଘ ! ޷͖ͳΤσΟλͰ ࡞੒ͯ͠େৎ෉ʂ
  8. GRUNT ࣮ߦʂ ! > grunt cssmin Running "cssmin:compress" (cssmin) task

    File css/kansei.css created: 60 B → 48 B ! Done, without errors. ͳΜ͔Ͱͨʂʂ