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

The Modern Web Developer's Toolkit

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

The Modern Web Developer's Toolkit

Avatar for Rob Sanchez

Rob Sanchez

June 28, 2013
Tweet

Other Decks in Programming

Transcript

  1. The Command-line • A succinct way of solving complicated (and

    often annoying) problems • If you are into keyboard shortcuts--you should embrace the CLI • GUIs can obscure problems and be harder to debug
  2. Portability • Multi-environment server-side configuration • Set up a local

    development environment as quickly as possible • Dependency management
  3. Standardization • Working in teams • Flow from one project

    to the next • Reduce the pain of turnover • Keep a boilerplate repo
  4. .profile • Located in your home directory, eg. /Users/ yourname/

    • shell script that gets executed every time you open a terminal • $PATH
  5. Installing Node.js and NPM • brew install node • add

    node path to your .profile • export PATH="$PATH:/usr/ local/share/npm/bin"
  6. Installing Ruby & bundler • brew install ruby (or don’t)

    • gem install bundler (might need sudo) •export PATH="/usr/local/opt/ ruby/bin:$PATH"
  7. Reducing asset size and # of HTTP requests • minification

    • concatenation • image optimization
  8. Starting a new project • bundle init - (generate a

    Gemfile) • npm init - (generate a package.json file) • compass init - (generate a config.rb file)
  9. SASS Nesting nav { width: 100%; ul { list-style: none;

    li { display: inline-block; } } }
  10. Compass CSS3 Vendor Prefixing .callout { @include transition(all 0.3s linear);

    @include opacity(0.8); &:hover { @include opacity(1); } }
  11. Compass rgbapng plugin • add gem 'rgbapng' to your Gemfile

    • add require 'rgbapng' to your config.rb
  12. Compass on the command-line • compass init - create a

    config.rb file • compass compile - compile to CSS • compass watch - watch for file changes & compile
  13. Grunt • task runner / build tool • concat/minify JS

    • optimize images • run sass/compass • watch for file changes + livereload
  14. Installing Grunt • npm install -g grunt-cli (install globally) •

    npm install grunt --save-dev (install locally, add to package.json)
  15. Gruntfile.js module.exports = function(grunt) { grunt.initConfig({ concat: { all: {

    src: [ '_src/js/plugins/*.js', '_src/js/modules/*.js', '_src/js/templates/*.js', '_src/js/site.js' ], dest: 'assets/js/site.js' } },
  16. Gruntfile.js uglify: { all: { src: 'assets/js/site.js', dest: 'assets/js/site.js' }

    } }); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.registerTask('default', [ 'concat', 'uglify']); };
  17. Running Grunt • grunt - run the default task •

    grunt concat - run the concat task • grunt compass:development - run the compass development sub-task • grunt watch - run the watch task
  18. Grunt JSHint • lint your code (aka check for syntax

    errors) • npm install grunt-contrib- jshint --save-dev • add grunt.loadNpmTasks('grunt- contrib-jshint'); to your Gruntfile
  19. Grunt Concat • combine files into one • npm install

    grunt-contrib- concat --save-dev • add grunt.loadNpmTasks('grunt- contrib-concat'); to your Gruntfile
  20. Grunt Concat grunt.initConfig({ concat: { all: { src: [ '_src/js/plugins/*.js',

    '_src/js/modules/*.js', '_src/js/site.js' ], dest: 'assets/js/site.js' } } });
  21. Grunt Uglify • compress/minify your JS • npm install grunt-contrib-

    uglify --save-dev • add grunt.loadNpmTasks('grunt- contrib-uglify'); to your Gruntfile
  22. Grunt Imagemin • optimize your raster graphics • npm install

    grunt-contrib- imagemin --save-dev • add grunt.loadNpmTasks('grunt- contrib-imagemin'); to your Gruntfile
  23. grunt.initConfig({ imagemin: { all: { options: { optimizationLevel: 4 },

    files: [{ expand: true, cwd: 'assets/images/', src: ['*.png', '*.jpg', '*.jpeg'], dest: 'assets/images/' }] } } });
  24. Grunt Compass • compile your SASS/Compass with grunt • npm

    install grunt-contrib- compass --save-dev • add grunt.loadNpmTasks('grunt- contrib-compass'); to your Gruntfile
  25. grunt.initConfig({ compass: { options: { require: ['rgbapng'], httpPath: '/', cssDir:

    'assets/css', sassDir: '_src/sass', imagesDir: 'assets/images', javascriptsDir: '_src/js', outputStyle: 'compressed', noLineComments: true } } });
  26. Grunt Watch • http://feedback.livereload.com/ knowledgebase/articles/86242 • watch for file changes

    + livereload • npm install grunt-contrib- watch --save-dev • add grunt.loadNpmTasks('grunt- contrib-watch'); to your Gruntfile
  27. grunt.initConfig({ watch: { options: { livereload: true }, compass: {

    files: [ '_src/sass/**/*.{sass,scss}', '_src/sprites/**/*.png'], tasks: ['compass'] }, js: { files: ['_src/js/**/*.js'], tasks: ['jshint', 'concat'] },
  28. html: { files: ['*.php', '*.html'] }, imagemin: { files: [

    'images/**/*.{png,jpg,jpeg}' ], tasks: ['imagemin'] } } });
  29. Other Grunt plugins • grunt-grunticon • grunt-webfont • grunt-imagemagick •

    grunt-svgmin • grunt-contrib-qunit, grunt-contrib-nodeunit