regexper-static/gulpfile.js

88 lines
2.2 KiB
JavaScript
Raw Normal View History

var gulp = require('gulp'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
config = require('./config');
function errorHandler() {
return plumber({
errorHandler: notify.onError('Error: <%= error.message %>')
});
}
gulp.task('default', ['server'], function() {
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']);
});
gulp.task('server', ['build'], function() {
2014-11-23 22:17:29 +00:00
var connect = require('gulp-connect'),
watch = require('gulp-watch');
watch(config.buildPath('**/*'), { name: 'Server' })
2014-11-23 17:24:03 +00:00
.pipe(connect.reload());
2014-11-23 17:24:03 +00:00
return connect.server({
root: config.buildRoot,
2014-11-23 17:24:03 +00:00
livereload: true
});
});
gulp.task('build', ['static', 'markup', 'compass', 'browserify']);
gulp.task('static', function() {
return gulp.src(config.globs.other, { base: './src' })
.pipe(errorHandler())
.pipe(gulp.dest(config.buildRoot));
});
gulp.task('markup', function() {
2014-11-23 22:17:29 +00:00
var wrap = require('gulp-wrap');
return gulp.src(config.globs.html, { base: './src' })
.pipe(errorHandler())
.pipe(wrap({ src: config.templateFile }))
.pipe(gulp.dest(config.buildRoot));
2014-11-23 21:16:10 +00:00
});
gulp.task('compass', function() {
2014-11-23 22:17:29 +00:00
var compass = require('gulp-compass');
return gulp.src(config.globs.sass)
.pipe(errorHandler())
.pipe(compass(config.compass));
});
2014-11-23 22:00:01 +00:00
gulp.task('browserify', function() {
var browserify = require('browserify'),
exorcist = require('exorcist'),
tap = require('gulp-tap'),
transform = require('vinyl-transform');
return gulp.src('./src/js/main.js', { read: false })
.pipe(errorHandler())
.pipe(tap(function(file) {
var bundler = browserify(config.browserify);
config.browserify.prebundle(bundler);
bundler.add(file.path);
file.contents = bundler.bundle();
}))
.pipe(transform(function() {
return exorcist(config.buildPath('js/main.js.map'));
}))
.pipe(gulp.dest(config.buildPath('js')));
2014-11-23 23:55:32 +00:00
});
2014-11-23 22:00:01 +00:00
gulp.task('karma', function(done) {
var karma = require('karma'),
path = require('path');
karma.server.start({
configFile: path.join(__dirname, 'karma.conf.js')
}, done);
2014-11-23 22:00:01 +00:00
});