Sencha Practice Director | @kazmiekrkevin.kazmierczak@universalmind.com
npm install -g grunt-cli
Doesn’t install the runner itself, runs the version of Grunt installed next to the Gruntfile
npm install grunt --save-dev
--save-dev will automatically add the installed package to your local package.json file
module.exports = function(grunt) { // Project configuration. grunt.initConfig( { pkg: grunt.file.readJSON('package.json'), uglify: { options: { banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' }, build: { src: 'src/<%= pkg.name %>.js', dest: 'build/<%= pkg.name %>.min.js' } } }); // Load the plugin that provides the "uglify" task. grunt.loadNpmTasks('grunt-contrib-uglify'); // Default task(s). grunt.registerTask('default', ['uglify']); };
grunt.initConfig({ concat: { foo: { // concat task "foo" target options and files go here. }, bar: { // concat task "bar" target options and files go here. }, }, uglify: { bar: { // uglify task "bar" target options and files go here. }, }, });
grunt.initConfig({ concat: { options: { // Task-level options may go here, overriding task defaults. }, foo: { options: { // "foo" target options may go here, overriding task-level options. }, }, bar: { // No options specified; this target will use task-level options. }, }, });
grunt.registerTask('foo', 'A sample task that logs stuff.', function(arg1, arg2) { if (arguments.length === 0) { grunt.log.writeln(this.name + ", no args"); } else { grunt.log.writeln(this.name + ", " + arg1 + " " + arg2); } });
Register them with npm with a ‘gruntplugin’ keyword
npm install -g gulp npm install --save-dev gulp gulp-util
var gulp = require('gulp'); var coffee = require('gulp-coffee'); var concat = require('gulp-concat'); var uglify = require('gulp-uglify'); var paths = { scripts: ['client/js/**/*.coffee', '!client/external/**/*.coffee'], images: 'client/img/**/*' }; gulp.task('scripts', function() { // Minify and copy all JavaScript (except vendor scripts) return gulp.src(paths.scripts) .pipe(coffee()) .pipe(uglify()) .pipe(concat('all.min.js')) .pipe(gulp.dest('build/js')); });