Last active
January 3, 2016 22:49
-
-
Save tonyhb/8531059 to your computer and use it in GitHub Desktop.
Base gulpfile.js for most projects - Gulp v3.5.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
// Plugins | |
var imagemin = require('gulp-imagemin'), | |
compass = require('gulp-compass'), | |
coffee = require('gulp-coffee'); | |
// Paths | |
var basePath = './public/assets/', | |
sassPath = basePath + 'sass/', | |
cssPath = basePath + 'css/', | |
coffeePath = basePath + 'coffee/', | |
jsPath = basePath + 'js/', | |
imagePath = basePath + 'images/'; | |
/** | |
* Compile SASS down to CSS using compass | |
*/ | |
var compileCSS = function() { | |
var stream = gulp.src(sassPath + '*.sass') | |
.pipe(compass({ | |
css: cssPath, | |
sass: sassPath, | |
image: imagePath, | |
style: 'compressed' | |
})) | |
.pipe(gulp.dest(cssPath)); | |
return stream; | |
}; | |
gulp.task('css', compileCSS); | |
gulp.task('sass', compileCSS); | |
/** | |
* Compile Coffee down to JS | |
*/ | |
var compileJS = function() { | |
var stream = gulp.src(coffeePath + '**/*.coffee') | |
.pipe(coffee({bare: true}).on('error', console.log)) | |
.pipe(gulp.dest(jsPath)); | |
return stream; | |
}; | |
gulp.task('coffee', compileJS); | |
gulp.task('js', compileJS); | |
/** | |
* Compress images through image-min | |
* !! Note: We also compress manually through ImageOptim before releasing. | |
* image-min only uses gifsicle, jpegtran and pngquant. | |
*/ | |
gulp.task('images', function() { | |
var stream = gulp.src(imagePath + '/**') | |
.pipe(imagemin()) | |
.pipe(gulp.dest(imagePath)); | |
return stream; | |
}); | |
gulp.task('watch', function() { | |
gulp.watch(sassPath + '**', ['css']); | |
gulp.watch(coffeePath + '**', ['js']); | |
}); | |
/** | |
* Default: this runs when you type gulp | |
*/ | |
gulp.task('default', ['css', 'js', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment