Created
December 31, 2013 14:13
-
-
Save hemanth/8197360 to your computer and use it in GitHub Desktop.
grunt vs gulp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
concat: { | |
options: { | |
separator: ';' | |
}, | |
dist: { | |
src: ['src/**/*.js'], | |
dest: 'dist/<%= pkg.name %>.js' | |
} | |
}, | |
uglify: { | |
dist: { | |
files: { | |
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>'] | |
} | |
} | |
}, | |
jshint: { | |
files: ['gruntfile.js', 'src/**/*.js', 'test/**/*.js'] | |
}, | |
watch: { | |
files: ['<%= jshint.files =>'], | |
tasks: ['jshint', 'concat', 'uglify'] | |
} | |
}); | |
// Load Our Plugins | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-contrib-concat'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
// Register Default Task | |
grunt.registerTask('default', ['jshint', 'concat', 'uglify']); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var jshint = require('gulp-jshint'); | |
var concat = require('gulp-concat'); | |
var rename = require('gulp-rename'); | |
var uglify = require('gulp-uglify'); | |
// Lint JS | |
gulp.task('lint', function() { | |
gulp.src('./src/*.js') | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')); | |
}); | |
// Concat & Minify JS | |
gulp.task('minify', function(){ | |
gulp.src('./src/*.js') | |
.pipe(concat('all.js')) | |
.pipe(gulp.dest('./dist')) | |
.pipe(rename('all.min.js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('./dist')); | |
}); | |
// Default | |
gulp.task('default', function(){ | |
gulp.run('lint', 'minify'); | |
// Watch JS Files | |
gulp.watch("./src/*.js", function(event){ | |
gulp.run('lint', 'minify'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment