Created
May 6, 2014 17:04
-
-
Save therebelrobot/73de6a3b20862b130128 to your computer and use it in GitHub Desktop.
I need to keep this handy. Hopefully it can help you too.
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 uglify = require('gulp-uglify'); | |
var concat = require('gulp-concat'); | |
var less = require('gulp-less'); | |
var minifyHTML = require('gulp-minify-html'); | |
var nodemon = require('gulp-nodemon'); | |
var jshint = require('gulp-jshint'); | |
var bump = require('gulp-bump'); | |
var ngmin = require('gulp-ngmin'); | |
var templates = require('gulp-angular-templatecache'); | |
var paths = { | |
scripts: { | |
ours: [ | |
'source/js/templates.js', | |
'source/js/**/*.js', | |
'!source/js/lib/**' | |
], | |
lib:[ | |
'bower_modules/jquery/dist/jquery.min.js', | |
'bower_modules/angular/angular.min.js', | |
'bower_modules/angular-route/angular-route.min.js', | |
'bower_modules/angular-resource/angular-resource.min.js', | |
'source/js/lib/**/*.js' | |
] | |
}, | |
styles: { | |
ourswatch:['source/less/**/*.less'], | |
ours:['source/less/main.less'], | |
lib:['source/less/lib/**/*.css'] | |
}, | |
images: 'source/img/**', | |
html:{ | |
index:['source/index.html'], | |
templates:['source/templates/**/*.html'], | |
}, | |
fonts:['source/assets/fonts/**'], | |
misc:['source/assets/misc/**'] | |
}; | |
gulp.task('lint', function () { | |
return gulp.src(['./auth.server.js','./private_modules/*.js']) | |
.pipe(jshint()) | |
}); | |
gulp.task('develop', function () { | |
return nodemon({ script: 'server.js', ext: 'js', ignore: ['source/**','build/**'] }) | |
.on('restart', ['lint']) | |
}); | |
gulp.task('angular-templates', function () { | |
return gulp.src(paths.html.templates) | |
.pipe(minifyHTML({empty: true,spare: true,quotes: true})) | |
.pipe(templates('templates.js', {standalone:true})) | |
.pipe(gulp.dest('source/js')); | |
}); | |
gulp.task('scripts-ours', function() { | |
return gulp.src(paths.scripts.ours) | |
.pipe(concat("main.js")) | |
.pipe(ngmin()) | |
.pipe(uglify()) | |
.pipe(gulp.dest('build/js')); | |
}); | |
gulp.task('scripts-lib', function() { | |
return gulp.src(paths.scripts.lib) | |
.pipe(concat("lib.js")) | |
.pipe(gulp.dest('build/js')); | |
}); | |
gulp.task('styles-ours', function () { | |
return gulp.src(paths.styles.ours) | |
.pipe(less()) | |
.pipe(gulp.dest('build/css')); | |
}); | |
gulp.task('styles-lib', function () { | |
return gulp.src(paths.styles.lib) | |
.pipe(concat("lib.css")) | |
.pipe(gulp.dest('build/css')); | |
}); | |
// Copy all static assets | |
gulp.task('copy-img', function() { | |
return gulp.src(paths.images) | |
.pipe(gulp.dest('build/img')); | |
}); | |
gulp.task('copy-index', function() { | |
return gulp.src(paths.html.index) | |
.pipe(gulp.dest('build')); | |
}); | |
gulp.task('copy-fonts', function() { | |
return gulp.src(paths.fonts) | |
.pipe(gulp.dest('build/fonts')); | |
}); | |
gulp.task('copy-misc', function() { | |
return gulp.src(paths.misc) | |
.pipe(gulp.dest('build/misc')); | |
}); | |
gulp.task('watch', function () { | |
gulp.watch(paths.scripts.ours, ['scripts-ours']); | |
gulp.watch(paths.scripts.lib, ['scripts-lib']); | |
gulp.watch(paths.styles.ourswatch, ['styles-ours']); | |
gulp.watch(paths.styles.lib, ['styles-lib']); | |
gulp.watch(paths.images, ['copy-img']); | |
gulp.watch(paths.html.index, ['copy-index']); | |
gulp.watch(paths.html.templates, ['angular-templates','scripts-ours']); | |
gulp.watch(paths.fonts, ['copy-fonts']); | |
gulp.watch(paths.misc, ['copy-misc']); | |
}); | |
gulp.task('bump.major', function(){ | |
return gulp.src(['./bower.json', './package.json']) | |
.pipe(bump({type:'major'})) | |
.pipe(gulp.dest('./')); | |
}); | |
gulp.task('bump.minor', function(){ | |
return gulp.src(['./bower.json', './package.json']) | |
.pipe(bump({type:'minor'})) | |
.pipe(gulp.dest('./')); | |
}); | |
gulp.task('bump.patch', function(){ | |
return gulp.src(['./bower.json', './package.json']) | |
.pipe(bump({type:'patch'})) | |
.pipe(gulp.dest('./')); | |
}); | |
// The default task (called when you run `gulp`) | |
gulp.task('default', [ | |
'scripts-lib', | |
'angular-templates', | |
'scripts-ours', | |
'styles-lib', | |
'styles-ours', | |
'copy-img', | |
'copy-index', | |
'copy-fonts', | |
'copy-misc', | |
'develop', | |
'watch' | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment