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

Grunt

sporto
November 26, 2013

 Grunt

sporto

November 26, 2013
Tweet

More Decks by sporto

Other Decks in Programming

Transcript

  1. Installing grunt Install grunt cli as global Install grunt as

    local Uses package.json to keep track of dependencies (devDependecies)
  2. Gruntfile module.exports = function(grunt) { ! grunt.initConfig({ uglify: { build:

    { src: 'src/<%= pkg.name %>.js', dest: 'build/<%= pkg.name %>.min.js' } } }); ! grunt.loadNpmTasks('grunt-contrib-uglify'); ! grunt.registerTask('default', ['uglify']); }; tasks config loading and registering tasks
  3. Just Node var foo = require(‘foo’); ! grunt.registerTask('foo', 'A task',

    function(arg1, arg2) { // You can do whatever you can with Node ! foo.doSomething(); });
  4. Async tasks grunt.registerTask('all', 'A task', function() { var done =

    this.async(); ! doSomethingAsync(done); }); $ grunt all
  5. Installing a plug-in $ npm install grunt-goserver --save-dev grunt.loadNpmTasks(‘grunt-goserver'); !

    grunt.initConfig({ goserver: { default: { srcPath: '/full/path/to/src/folder', … }, }, }) In Gruntfile.js