Skip to content

Instantly share code, notes, and snippets.

@digilord
Created February 28, 2014 01:55
Show Gist options
  • Save digilord/9263727 to your computer and use it in GitHub Desktop.
Save digilord/9263727 to your computer and use it in GitHub Desktop.
// var gulp = require('gulp'),
// coffee = require('gulp-coffee'),
// coffeelint = require('gulp-coffeelint'),
// gutil = require('gulp-util'),
// todo = require('gulp-todo'),
// source = require('vinyl-source-stream'),
// watchify = require('watchify'),
// header = require('gulp-header'),
// pkg = require('./package'),
// 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', ['less:dev', 'img:dev', 'js:dev', 'static']);
// gulp.task('build', ['less', 'img', 'js']);
// gulp.task('watch', function () {
// var bundler = watchify('./src/index.js');
// // Optionally, you can apply transforms
// // and other configuration options on the
// // bundler just as you would with browserify
// bundler.transform('brfs')
// bundler.on('update', rebundle)
// function rebundle () {
// return bundler.bundle()
// .pipe(source('bundle.js'))
// .pipe(gulp.dest('./dist'))
// }
// return rebundle()
// });
// 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', function() {
// gulp.src('./src/*.coffee')
// .pipe(coffee({bare: true}).on('error', gutil.log))
// .pipe(gulp.dest('./src/'))
// });
// gulp.task('lint', function () {
// gulp.src('./src/*.coffee')
// .pipe(coffeelint())
// .pipe(coffeelint.reporter())
// });
(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'),
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', '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('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() {
return gulp.src(['app/js/**'])
.pipe(watch())
.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