* gulp
* $ npm install gulp-coffee gulp-ruby-sass gulp-autoprefixer gulp-minify-css gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
var gulp = require('gulp'),
coffee = require('gulp-coffee'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
notify = require('gulp-notify'),
cache = require('gulp-cache'),
livereload = require('gulp-livereload'),
del = require('del');
var paths = {
sass: 'sass/all.sass',
js: 'js/**/*.js',
images: 'images/**/*',
coffee: 'coffee/**/*.coffee'
};
gulp.task('styles', function() {
return sass(paths.sass, { style: 'expanded' })
.pipe(autoprefixer('last 2 version'))
.pipe(gulp.dest('assets/css'))
.pipe(notify({ message: 'Styles task complete' }));
});
gulp.task('scripts', function() {
return gulp.src(paths.js)
.pipe(jshint.reporter('default'))
.pipe(concat('main.js'))
.pipe(gulp.dest('assets/js'))
.pipe(notify({ message: 'Scripts task complete' }));
});
gulp.task('images', function() {
return gulp.src(paths.images)
.pipe(cache(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true })))
.pipe(gulp.dest('assets/images'))
.pipe(notify({ message: 'Images task complete' }));
});
gulp.task('coffee', function() {
gulp.src(paths.coffee)
.pipe(coffee())
.pipe(gulp.dest('assets/js'))
.pipe(notify({ message: 'Coffee task complete' }));
});
gulp.task('clean', function(cb) {
del(['assets/assets/css', 'assets/assets/js', 'assets/assets/img'], cb)
});
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'scripts', 'images', 'coffee', 'watch');
});
gulp.task('webserver', function() {
connect.server({
livereload: true
});
});
gulp.task('watch', function() {
gulp.watch('sass/**/*.sass', ['styles']);
gulp.watch('js/**/*.js', ['scripts']);
gulp.watch('images/**/*', ['images']);
gulp.watch('coffee/**/**.coffee', ['coffee']);
livereload.listen();
gulp.watch(['assets/**']).on('change', livereload.changed);
});