2014-11-23 22:26:05 +00:00
|
|
|
var gulp = require('gulp'),
|
2014-11-23 22:50:30 +00:00
|
|
|
notify = require('gulp-notify'),
|
|
|
|
plumber = require('gulp-plumber'),
|
2014-11-23 22:26:05 +00:00
|
|
|
config = require('./config');
|
2014-11-23 16:52:45 +00:00
|
|
|
|
2014-11-23 22:50:30 +00:00
|
|
|
function errorHandler() {
|
|
|
|
return plumber({
|
|
|
|
errorHandler: notify.onError('Error: <%= error.message %>')
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-11-23 17:31:52 +00:00
|
|
|
gulp.task('default', ['server'], function() {
|
2014-11-23 22:26:05 +00:00
|
|
|
gulp.watch(config.globs.other, ['static']);
|
|
|
|
gulp.watch([config.globs.html, config.templateFile], ['markup']);
|
|
|
|
gulp.watch(config.globs.sass, ['compass']);
|
|
|
|
gulp.watch(config.globs.js, ['browserify']);
|
2014-11-23 16:52:45 +00:00
|
|
|
});
|
2014-11-23 17:00:07 +00:00
|
|
|
|
2014-11-23 22:13:24 +00:00
|
|
|
gulp.task('server', ['build'], function() {
|
2014-11-23 22:17:29 +00:00
|
|
|
var connect = require('gulp-connect'),
|
|
|
|
watch = require('gulp-watch');
|
|
|
|
|
2014-11-23 17:24:03 +00:00
|
|
|
watch('./build/**/*', { name: 'Server' })
|
|
|
|
.pipe(connect.reload());
|
2014-11-23 22:50:30 +00:00
|
|
|
|
2014-11-23 17:24:03 +00:00
|
|
|
return connect.server({
|
|
|
|
root: './build',
|
|
|
|
livereload: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-11-23 22:13:24 +00:00
|
|
|
gulp.task('build', ['static', 'markup', 'compass', 'browserify']);
|
|
|
|
|
2014-11-23 21:29:40 +00:00
|
|
|
gulp.task('static', function() {
|
2014-11-23 22:26:05 +00:00
|
|
|
return gulp.src(config.globs.other)
|
2014-11-23 22:50:30 +00:00
|
|
|
.pipe(errorHandler())
|
2014-11-23 21:29:40 +00:00
|
|
|
.pipe(gulp.dest('./build'));
|
|
|
|
});
|
|
|
|
|
2014-11-23 17:00:07 +00:00
|
|
|
gulp.task('markup', function() {
|
2014-11-23 22:17:29 +00:00
|
|
|
var wrap = require('gulp-wrap');
|
|
|
|
|
2014-11-23 22:26:05 +00:00
|
|
|
return gulp.src(config.globs.html)
|
2014-11-23 22:50:30 +00:00
|
|
|
.pipe(errorHandler())
|
2014-11-23 22:26:05 +00:00
|
|
|
.pipe(wrap({ src: config.templateFile }))
|
2014-11-23 21:16:10 +00:00
|
|
|
.pipe(gulp.dest('./build'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('compass', function() {
|
2014-11-23 22:17:29 +00:00
|
|
|
var compass = require('gulp-compass');
|
|
|
|
|
2014-11-23 22:26:05 +00:00
|
|
|
return gulp.src(config.globs.sass)
|
2014-11-23 22:50:30 +00:00
|
|
|
.pipe(errorHandler())
|
2014-11-23 22:26:05 +00:00
|
|
|
.pipe(compass(config.compass));
|
2014-11-23 17:00:07 +00:00
|
|
|
});
|
2014-11-23 22:00:01 +00:00
|
|
|
|
|
|
|
gulp.task('browserify', function() {
|
2014-11-23 22:17:29 +00:00
|
|
|
var browserify = require('browserify'),
|
|
|
|
es6ify = require('es6ify'),
|
2014-11-23 22:50:30 +00:00
|
|
|
tap = require('gulp-tap');
|
2014-11-23 22:00:01 +00:00
|
|
|
|
2014-11-23 22:50:30 +00:00
|
|
|
return gulp.src('./src/js/main.js', { read: false })
|
|
|
|
.pipe(errorHandler())
|
|
|
|
.pipe(tap(function(file) {
|
|
|
|
var bundler = browserify(config.browserify);
|
2014-11-23 22:00:01 +00:00
|
|
|
|
2014-11-23 22:50:30 +00:00
|
|
|
bundler.add([file.path, es6ify.runtime]);
|
|
|
|
bundler.transform(es6ify);
|
|
|
|
|
|
|
|
file.contents = bundler.bundle();
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('./build/js'));
|
2014-11-23 22:00:01 +00:00
|
|
|
});
|