Created
December 29, 2013 14:37
-
-
Save Sigmus/8171005 to your computer and use it in GitHub Desktop.
Migrating some configuration from Gruntfile.js to gulpfile.js
This file contains hidden or 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 browserify = require('gulp-browserify'); | |
var less = require('gulp-less'); | |
var concat = require('gulp-concat'); | |
var jshint = require('gulp-jshint'); | |
var outDir = null; | |
var sources = { | |
scripts: './app/scripts/**/*.js', | |
less: './app/styles/**/*.less', | |
copy: [ | |
{src: './app/templates/*', dest: ''}, | |
{src: './app/images/*', dest: 'images'} | |
], | |
browserify: './app/scripts/main.js' | |
}; | |
gulp.task('default', function () { | |
gulp.run('temp'); | |
}); | |
gulp.task('temp', function() { | |
outDir = './temp'; | |
gulp.run('copy', 'less', 'jshint', 'browserify'); | |
gulp.watch(sources.less, function() { | |
gulp.run('less'); | |
}); | |
sources.copy.forEach(function(item) { | |
gulp.watch(item.src, function() { | |
gulp.run('copy'); | |
}); | |
}); | |
gulp.watch(sources.scripts, function() { | |
gulp.run('jshint'); | |
}); | |
gulp.watch(sources.browserify, function() { | |
gulp.run('browserify'); | |
}); | |
}); | |
gulp.task('copy', function () { | |
sources.copy.forEach(function(item) { | |
gulp.src(item.src) | |
.pipe(gulp.dest(outDir + '/' + item.dest)) | |
}); | |
}); | |
gulp.task('less', function () { | |
gulp.src(sources.less) | |
.pipe(less({compress: false})) | |
.pipe(gulp.dest(outDir + '/styles')); | |
}); | |
gulp.task('jshint', function() { | |
gulp.src(sources.scripts) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('jshint-stylish')) | |
}); | |
gulp.task('browserify', function() { | |
gulp.src(sources.browserify) | |
.pipe(browserify()) | |
.pipe(concat('main.js')) | |
.pipe(gulp.dest(outDir + '/scripts/')) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@contra Cool!