-
-
Save davidhemphill/d553e770cf9869f3e987 to your computer and use it in GitHub Desktop.
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
(function() { | |
'use strict'; | |
var gulp = require('gulp'), | |
gutil = require('gulp-util'), | |
dot = require('gulp-dot'), | |
less = require('gulp-less'), | |
sass = require('gulp-sass'), | |
rm = require('rimraf'), | |
reload = require('gulp-livereload'), | |
imagemin = require('gulp-imagemin'), | |
concat = require('gulp-concat'), | |
uglify = require('gulp-uglify'), | |
watch = require('gulp-watch'), | |
header = require('gulp-header'), | |
pkg = require('./package'), | |
todo = require('gulp-todo'), | |
autoprefixer = require('gulp-autoprefixer'), | |
coffee = require('gulp-coffee'), | |
coffeelint = require('gulp-coffeelint'), | |
banner; | |
banner = '/*!\n' + | |
' * ' + pkg.name + ' - ' + pkg.description + '\n' + | |
' * ' + pkg.url + '\n' + | |
' * @author ' + pkg.author + '\n' + | |
' * @version ' + pkg.version + '\n' + | |
' * Copyright ' + pkg.copyright + '. ' + pkg.license + ' licensed.\n' + | |
' */\n'; | |
gulp.task('serve', ['todo', 'coffee:dev', 'coffee:lint', 'html:dev', 'dot:dev', 'less:dev', 'img:dev', 'js:dev', 'static']); | |
gulp.task('build', ['todo', 'html', 'dot', 'less', 'img', 'js']); | |
gulp.task('todo', function() { | |
gulp.src('app/js/*.js') | |
.pipe(todo()) | |
.pipe(gulp.dest('./')); | |
}); | |
gulp.task('static', function(next) { | |
var staticS = require('node-static'); | |
var server = new staticS.Server('./build'); | |
require('http').createServer(function (request, response) { | |
request.addListener('end', function () { | |
server.serve(request, response); | |
}).resume(); | |
}).listen(8080, next); | |
}); | |
gulp.task('coffee:dev', ['clean:dev'], function() { | |
gulp.src('app/js/*.coffee') | |
.pipe(watch()) | |
.pipe(coffee({bare: true}).on('error', gutil.log)) | |
.pipe(gulp.dest('app/js')); | |
return gulp.src('app/js/*.coffee') | |
.pipe(watch()) | |
.pipe(coffee({bare: true}).on('error', gutil.log)) | |
.pipe(gulp.dest('app/js')); | |
}); | |
gulp.task('coffee:lint', function () { | |
gulp.src('app/js/*.coffee') | |
.pipe(watch()) | |
.pipe(coffeelint("coffeelint.json")) | |
.pipe(coffeelint.reporter()) | |
return gulp.src('app/js/*.coffee') | |
.pipe(watch()) | |
.pipe(coffeelint("coffeelint.json")) | |
.pipe(coffeelint.reporter()) | |
}); | |
gulp.task('dot:dev', ['clean:dev'], function() { | |
gulp.src('app/layouts/*.dot', {read: false}) | |
.pipe(watch()) | |
.pipe(reload()); | |
return gulp.src('app/*.dot') | |
.pipe(watch()) | |
.pipe(dot({layout: 'app/layouts/dev.dot'})) | |
.pipe(gulp.dest('build')) | |
.pipe(reload()); | |
}); | |
gulp.task('dot', ['clean'], function() { | |
return gulp.src('app/*.dot') | |
.pipe(dot({layout: 'app/layouts/prod.dot'})) | |
.pipe(gulp.dest('build')); | |
}); | |
gulp.task('html:dev',['clean:dev'], function(){ | |
gulp.src('app/**/*.html') | |
.pipe(watch()) | |
.pipe(reload()); | |
return gulp.src('app/**/*.html') | |
.pipe(watch()) | |
.pipe(gulp.dest('build')) | |
.pipe(reload()); | |
}); | |
gulp.task('html',['clean'], function(){ | |
gulp.src('app/**/*.html') | |
.pipe(watch()) | |
.pipe(reload()); | |
return gulp.src('app/**/*.html') | |
.pipe(watch()) | |
.pipe(gulp.dest('dist')) | |
.pipe(reload()); | |
}); | |
gulp.task('less:dev', ['clean:dev'], function() { | |
return gulp.src('app/less/style.less') | |
.pipe(watch()) | |
.pipe(less()) | |
.pipe(autoprefixer('last 1 version')) | |
.pipe(gulp.dest('build/css')) | |
.pipe(reload()); | |
}); | |
gulp.task('less', ['clean'], function() { | |
return gulp.src('app/less/style.less') | |
.pipe(less({compress:true})) | |
.pipe(autoprefixer('last 1 version')) | |
.pipe(header(banner)) | |
.pipe(gulp.dest('dist/css')); | |
}); | |
gulp.task('img:dev', ['clean:dev'], function() { | |
return gulp.src(['app/img/**']) | |
.pipe(watch()) | |
.pipe(gulp.dest('build/img')) | |
.pipe(reload()); | |
}); | |
gulp.task('img', ['clean'], function() { | |
return gulp.src(['app/img/**']) | |
.pipe(imagemin()) | |
.pipe(gulp.dest('dist/img')); | |
}); | |
gulp.task('js:dev', ['clean:dev'], function() { | |
gulp.src(['app/js/*.js']) | |
.pipe(concat('app.js')) | |
.pipe(gulp.dest('build/js')) | |
return gulp.src(['app/js/*.js']) | |
.pipe(watch()) | |
.pipe(concat('app.js')) | |
.pipe(gulp.dest('build/js')) | |
.pipe(reload()); | |
}); | |
gulp.task('js', ['clean'], function() { | |
return gulp.src(['app/js/**']) | |
.pipe(concat('app.js')) | |
.pipe(uglify()) | |
.pipe(header(banner)) | |
.pipe(gulp.dest('dist/js')); | |
}); | |
gulp.task('sass:dev', ['clean:dev'], function() { | |
return gulp.src('app/sass/style.scss') | |
.pipe(watch()) | |
.pipe(sass()) | |
.pipe(gulp.dest('build/css')) | |
.pipe(reload()); | |
}); | |
gulp.task('sass', ['clean'], function() { | |
return gulp.src('app/sass/style.scss') | |
.pipe(sass({outputStyle: 'compressed'})) | |
.pipe(header(banner)) | |
.pipe(gulp.dest('dist/css')); | |
}); | |
gulp.task('clean:dev', function(next) { | |
rm('build/', function() { | |
next(); | |
}); | |
}); | |
gulp.task('clean', function(next) { | |
rm('dist/', function() { | |
next(); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment