Skip to content

Instantly share code, notes, and snippets.

@Sigmus
Created December 29, 2013 14:37
Show Gist options
  • Save Sigmus/8171005 to your computer and use it in GitHub Desktop.
Save Sigmus/8171005 to your computer and use it in GitHub Desktop.
Migrating some configuration from Gruntfile.js to gulpfile.js
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/'))
});
@Sigmus
Copy link
Author

Sigmus commented Dec 30, 2013

@contra Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment