Created
August 11, 2014 20:28
-
-
Save lsamayoa/dfbd121d53bfe884a270 to your computer and use it in GitHub Desktop.
Base Gulpfile RAW copy of production code
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'), | |
gutil = require('gulp-util'), | |
connect = require('gulp-connect'), | |
watch = require('gulp-watch'), | |
less = require('gulp-less'), | |
uglify = require('gulp-uglify'), | |
concat = require('gulp-concat'), | |
rename = require('gulp-rename'), | |
ngmin = require('gulp-ngmin'), | |
autoprefixer = require('gulp-autoprefixer'), | |
minifycss = require('gulp-minify-css'), | |
bower = require('gulp-bower'), | |
coffee = require('gulp-coffee'), | |
tar = require('gulp-tar'), | |
clean = require('gulp-clean'), | |
gzip = require('gulp-gzip'); | |
gulp.task('webserver', function() { | |
connect.server({ | |
livereloadscripts: true, | |
root: ['dist'] | |
}); | |
}); | |
gulp.task('livereload', function() { | |
return gulp.src(['dist/scripts/*.js', 'dist/styles/*.css', 'index.html']) | |
.pipe(watch()) | |
.pipe(connect.reload()); | |
}); | |
gulp.task('less', function() { | |
return gulp.src('styles/*.less') | |
.pipe(less()) | |
.pipe(gulp.dest('dist/styles')) | |
.pipe(concat('all.css')) | |
.pipe(autoprefixer("last 1 version")) | |
.pipe(gulp.dest('dist/styles/')) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(minifycss()) | |
.pipe(gulp.dest('dist/styles/')) | |
}); | |
gulp.task('precompile-templates',function () { | |
return gulp.src(['partials/**/*.html']) | |
.pipe(gulp.dest('dist/partials/')); | |
}); | |
gulp.task('publish-index', function () { | |
return gulp.src(['index.html']) | |
.pipe(gulp.dest('dist/')); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch('styles/*.less', ['less']); | |
gulp.watch('scripts/*.coffee', ['coffee']); | |
gulp.watch('partials/**/*.html', ['precompile-templates']); | |
gulp.watch('index.html', ['publish-index']); | |
}); | |
gulp.task('coffee', function(){ | |
return gulp.src('scripts/*.coffee') | |
.pipe(coffee()) | |
.on('error', gutil.log) | |
.on('error', gutil.beep) | |
.pipe(gulp.dest('dist/scripts/')) | |
.pipe(concat('all.js')) | |
.pipe(gulp.dest('dist/scripts/')) | |
.pipe(rename({suffix: '.min'})) | |
.pipe(uglify()) | |
.pipe(gulp.dest('dist/scripts/')) | |
}); | |
gulp.task('clean', function () { | |
return gulp.src('dist/*', {read: false}) | |
.pipe(clean()); | |
}); | |
gulp.task('bower', function() { | |
return bower() | |
.pipe(gulp.dest('dist/lib/')); | |
}); | |
gulp.task('build', ['bower', 'coffee', 'less', 'precompile-templates', 'publish-index']); | |
gulp.task('tarball', ['build'], function () { | |
return gulp.src('dist/**/*.*') | |
.pipe(tar('build.tar')) | |
.pipe(gzip()) | |
.pipe(gulp.dest('dist/tarball/')); | |
}); | |
gulp.task('default', ['build', 'webserver', 'livereload', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment