Skip to content

Instantly share code, notes, and snippets.

@mortennajbjerg
Created February 3, 2014 09:29
Show Gist options
  • Save mortennajbjerg/8780961 to your computer and use it in GitHub Desktop.
Save mortennajbjerg/8780961 to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var coffee = require('gulp-coffee');
var stylus = require('gulp-stylus');
// Copy assets
gulp.task('assets', function() {
gulp.src('client/assets/**')
.pipe(gulp.dest('./'));
});
// Get and render all .styl files recursively
gulp.task('stylus', function () {
gulp.src('client/css/**/*.styl')
.pipe(stylus())
.pipe(gulp.dest('./css'));
});
gulp.task('coffee', function() {
gulp.src('client/js/*.coffee')
.pipe(coffee({bare: true}).on('error', gutil.log))
.pipe(gulp.dest('./js'))
});
gulp.task('images', function(){
return gulp.src('client/assets/img/**')
// Pass in options to the task
.pipe(imagemin({optimizationLevel: 5}))
.pipe(gulp.dest('img'));
});
gulp.task('scripts', function() {
// Minify and copy all JavaScript (except vendor scripts)
return gulp.src(['client/js/*.js'])
.pipe(uglify())
.pipe(gulp.dest('js'));
});
// Rerun the task when a file changes
gulp.task('watch', function () {
gulp.watch('client/js/**', ['coffee', 'scripts']);
gulp.watch('client/img/**', ['images']);
gulp.watch('client/css/**', ['stylus']);
gulp.watch('client/assets/**', ['assets']);
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['assets', 'coffee', 'scripts', 'images', 'stylus', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment