Skip to content

Instantly share code, notes, and snippets.

@randomdrake
Last active January 25, 2016 11:38
Show Gist options
  • Save randomdrake/9474866 to your computer and use it in GitHub Desktop.
Save randomdrake/9474866 to your computer and use it in GitHub Desktop.
My Current Gulp File for Making Development Awesome
// Our Gulp packages we want to use
var gulp = require('gulp'),
gutil = require('gulp-util'),
notify = require('gulp-notify'),
sass = require('gulp-ruby-sass'),
coffee = require('gulp-coffee'),
autoprefix = require('gulp-autoprefixer'),
phpunit = require('gulp-phpunit'),
rename = require('gulp-rename'),
liveReload = require('gulp-livereload');
// Fire up our livereload server
var server = liveReload();
// Directories where we can find our files
var sassDir = 'app/Goldmine/assets/sass',
coffeeDir = 'app/Goldmine/assets/coffee',
testsDir = 'app/tests',
viewsDir = 'app/views',
targetCSSDir = 'public/css',
targetJSDir = 'public/js';
// Compiles all of the SASSy goodness
gulp.task('css', function() {
gulp.src(sassDir + '/main.scss')
.pipe(sass().on('error', gutil.log))
.pipe(autoprefix('last 10 versions'))
.pipe(gulp.dest(targetCSSDir))
.pipe(rename({ suffix: '.min' }))
.pipe(liveReload(server))
.pipe(notify('CSS Compiled, Prefixed and Minified...'));
});
// Compiles all of the coffee into wonderful script
gulp.task('coffee', function() {
gulp.src(coffeeDir + '/**/*.coffee')
.pipe(coffee().on('error', gutil.log))
.pipe(gulp.dest(targetJSDir))
.pipe(liveReload(server))
.pipe(notify('JS Compiled from CoffeeScript...'));
});
// Run the unit tests for the application
gulp.task('phpunit', function() {
var options = {debug: false, notify: true};
gulp.src(testsDir + '/*.php')
.pipe(phpunit('', options))
.on('error', notify.onError({
title: "Failed tests! You fool!",
message: "Error(s) occurred during testing..."
}))
.pipe(notify('PHPUnit Tests Run'));
});
// Setup our watchers
gulp.task('watch', function() {
gulp.watch(sassDir + '/**/*.sass', ['css']),
gulp.watch(coffeeDir + '/**/*.coffee', ['coffee']),
gulp.watch(viewsDir + '/*.php').on('change', function(file) {
server.changed(file.path);
});
gulp.watch(testsDir + '/*.php', ['phpunit'])
});
gulp.task('default', ['css', 'coffee', 'phpunit', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment