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

Grunt all day!

Grunt all day!

Grunt has fast become the defacto workflow workhorse in the modern web developers tool kit. This session will introduce you to using Grunt in your daily routines as well as surrounding technologies. Drop in for a brief introduction to Node and NPM, the Node Package Manager. Following that we will deep dive into Grunt and other strange noises like Bower, SASS, Lint, or live-reload.

Douglas Knudsen

October 11, 2014
Tweet

More Decks by Douglas Knudsen

Other Decks in Technology

Transcript

  1. me twitter: douglasknudsen ! G+: douglasknudsen ! email: [email protected] !

    blog: http://www.cubicleman.com ! https://github.com/douglasknudsen
  2. agenda • why oh why • enter Grunt! • but

    first, some node • and some npm • onto grunt • plugins galore
  3. node JS all up in your server! evented I/O for

    the V8 JS engine cylonjs, hummingbird, johnny-five, AWS, machine_learning
  4. node var net = require('net'); ! var server = net.createServer(function

    (socket) { socket.write('Echo server\r\n'); socket.pipe(socket); }); ! server.listen(1337, '127.0.0.1');
  5. node : npm enter npm node package manager comes with

    node though its not really a acronym
  6. node : npm libraries can be installed globally or locally

    npm install -g yo npm install lodash
  7. npm : package.json { "name": "david-tucker-site", "version": "0.0.6", "author": "David

    Tucker", "description": "The Personal Blog of David Tucker at davidtucker.net", "devDependencies": { "browserify-shim": "~2.0.3", "grunt-contrib-jshint": "~0.4.3", "grunt-contrib-sass": "~0.3.0" } } npm init
  8. grunt : gruntfile module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'),

    concat: { options: { separator: ';' }, dist: { src: ['src/**/*.js'], dest: 'dist/<%= pkg.name %>.js' } } }); grunt.loadNpmTasks(‘grunt-contrib-concat'); };
  9. grunt : gruntfile cssmin: { production: { expand: true, cwd:

    'css', src: ['*.css'], dest: 'css' }, dev: { expand: false, cwd: 'css', src: ['*.css'], dest: 'css' } } task target
  10. grunt : cssmin compass: { dist: { options: { cssDir:

    ['<%= distdir %>/css'], sassDir: ['src/styles'], noLineComments: true, importPath: ['bower_components/bootstrap-sass-official'], force: true } }, dev: { options: { cssDir: ['<%= distdir %>/css'], sassDir: ['src/styles'], importPath: ['bower_components/bootstrap-sass-official'] }
  11. grunt : jshint jshint:{ files:['gruntFile.js', '<%= src.js %>', '<%= src.jsTpl

    %>', '<%= src.specs %>', '<%= src.scenarios %>'], options:{ curly:true, eqeqeq:true, immed:true, latedef:true, newcap:true, noarg:true, sub:true, boss:true, eqnull:true, globals:{} } }
  12. grunt : watch watch:{ options: { livereload:true }, js: {

    files: ['<%= src.js %>'], tasks: ['js', 'timestamp'] }, css: { files: ['<%= src.sass %>'], tasks: ['css', 'timestamp'] }
  13. grunt : tl;dr • install node • npm install -g

    grunt-cli • cd /../your/project../ • npm init • npm install grunt --save-dev • touch Gruntfile.js • add tasks to Gruntfile.js • grunt!
  14. grunt : other yes folks, you can make maven grunt

    yes folks, you can make nuget grunt
  15. yo : webapp • html5 boilerplate • twiiter bootstrap •

    sass • structure • build • jasmine • karma • phantomjs • dependencies via bower • …
  16. yo : angular npm install -g generator-angular yo angular yo

    angular:controller myController yo angular:directive myDirective
  17. yo many many generators • angular • jhipster • ember

    • backbone • meanstack • karma • symfony • foundation
  18. yo don’t see one you need? don’t like the way

    a generator works? my team has a different way! role your own! http://yeoman.io/authoring/
  19. gulp gulp is on the horizon still kind of new

    http://gulpjs.com/ code-over-configuration
  20. resources • http://davidtucker.net/articles/automating-with-grunt • https://www.npmjs.org/ • http://www.slideshare.net/RahulNanwani/integrating- grunt-and-bower-with-maven • https://www.npmjs.org/package/grunt-nuget

    • http://yeoman.io/ • http://gruntjs.com/ • https://github.com/angular-app/angular-app • http://joelhooks.com/ • http://cliffmeyers.com/ • http://livereload.com/ • https://egghead.io/technologies/grunt