Created
July 23, 2014 06:43
-
-
Save dgtlmonk/cd9bf8bb69cc0c8f28b9 to your computer and use it in GitHub Desktop.
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
/* | |
* Gulp version of DDAB QA Preview Grunt Task runner | |
* @author: Joel Pablo | |
* | |
* */ | |
var gulp = require('gulp'), | |
gutil = require('gulp-load-utils')(['date','colors','log']), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglifyjs'), | |
csscomb = require('gulp-csscomb'), | |
compass = require('gulp-compass'), | |
livereload = require('gulp-livereload'), | |
plumber = require('gulp-plumber'), | |
bump = require('gulp-bump'), | |
pkg = require('./package.json'), // package.json | |
pkgName = pkg.title || pkg.name; | |
// helpers | |
function getMeta () { | |
return '/*! ' + pkgName + ' - v ' + pkg.version + ' - ' + gutil.date("yyyy-mm-dd") + '\n' + '* Copyright (c) ' + gutil.date("yyyy") + pkg.author + '*/'; | |
} | |
var onErr = function (e) { | |
console.log('Error has occured: ' + e); | |
} | |
var meta = { | |
banner: getMeta() | |
} | |
// console.log(meta.banner); | |
// Path maps ------------------------------------ | |
var loc = { | |
// common js: | |
jsCommon: '../../../common/', | |
// common js - for custom layouts: | |
jsCommonCustom: '../../../common/custom-layouts/js/', | |
// project specific custom js: | |
jsCustom: 'js/', | |
cssDest: './css' | |
}; | |
var concatFile = loc.jsCustom + pkgName + '.concat.js'; | |
// SCSS target files ------------------------------ | |
var creativeSizes = [ | |
// ADD CREATIVE SIZES BELOW -------- | |
'300x250', | |
]; | |
var scssPath = 'sass/', | |
scssSourceList = [], // stylesheeet list to be filled i.e: 'sass/300x250.scss' | |
cssSourceList = []; // stylesheeet list to be filled i.e: 'sass/300x250.css' | |
for (var sizes in creativeSizes) { | |
scssSourceList.push(scssPath + creativeSizes[sizes] + '.scss'); | |
cssSourceList.push(scssPath + creativeSizes[sizes] + '.css'); | |
} | |
// console.log(scssSourceList); | |
// console.log(scssSourceList); | |
// define tasks ---------------------------------- | |
gulp.task('concat', function(){ | |
gutil.log( gutil.colors.white.bold('// Concat task >> ' + concatFile + ' to ' + loc.jsCustom + pkgName + '.concat.js ...')); | |
return gulp.src([ | |
/*Libraries*/ | |
loc.jsCommonCustom + 'lib/webfont.js', | |
loc.jsCommonCustom + 'lib/greenstock/TweenLite.min.js', | |
loc.jsCommonCustom + 'lib/greenstock/CSSPlugin.min.js', | |
/*Common Utils*/ | |
loc.jsCommonCustom + 'utils_min.3.js', | |
loc.jsCommonCustom + 'utils-type-conversion.js', | |
/*Custom Layout AngularJS */ | |
loc.jsCommonCustom + 'bootstrap.js', | |
loc.jsCommonCustom + 'directives.js', | |
loc.jsCommonCustom + 'services.js', | |
loc.jsCommonCustom + 'controllers.js', | |
/*Custom Code*/ | |
loc.jsCustom + 'custom.js', | |
]) | |
.pipe(plumber({ | |
errorHandler: onErr | |
})) | |
.pipe(concat(pkgName + '.concat.js')) | |
.pipe(gulp.dest(loc.jsCustom)) | |
}) | |
// uglify task --------------------------- | |
gulp.task('uglify', function(){ | |
gutil.log( gutil.colors.white.bold('// Uglifying >> ' + concatFile + ' to ' + pkgName + '.min.js ...')); | |
return gulp.src(concatFile) | |
.pipe(plumber({ | |
errorHandler: onErr | |
})) | |
.pipe(uglify( pkgName + '.min.js', { | |
// uglify options | |
})) | |
.pipe(gulp.dest(loc.jsCustom)) | |
}) | |
// Compass task --------------------------- | |
gulp.task('compass', function(){ | |
gutil.log( gutil.colors.white.bold('// Compass task running ...')); | |
return gulp.src(scssSourceList) | |
.pipe(plumber({ | |
errorHandler: onErr | |
})) | |
.pipe(compass({ | |
sass:scssPath, | |
css:loc.cssDest, | |
comment: false | |
})) | |
.pipe(gulp.dest(loc.cssDest)) | |
.pipe(livereload()) | |
}) | |
// CSSComb task --------------------------- | |
gulp.task('csscomb', function(){ | |
return gulp.src(cssSourceList) | |
.pipe(csscomb()) | |
.pipe(gulp.dest(loc.cssDest)) | |
}) | |
// Bump task ------------------------------ | |
gulp.task('bump', function(){ | |
return gulp.src('./package.json') | |
.pipe(bump({ | |
type:'minor', | |
indent: 4 | |
})) | |
.pipe(gulp.dest('./')) | |
}) | |
// Watch task ---------------------------- | |
gulp.task('watch',function(){ | |
gulp.watch(scssSourceList,['compass']); | |
}) | |
gulp.task('default',['bump','concat','uglify','compass','watch']); | |
gulp.task('js',['bump','concat','uglify']); | |
gulp.task('css',['compass']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
package.json