Last active
August 29, 2015 13:57
-
-
Save beautyfree/9814362 to your computer and use it in GitHub Desktop.
This file contains 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'); | |
var jade = require('gulp-jade'), | |
uglify = require('gulp-uglify'), | |
concat = require('gulp-concat'), | |
plumber = require('gulp-plumber'), | |
sass = require('gulp-sass'), | |
imagemin = require('gulp-imagemin'); | |
var paths = { | |
templates: { | |
src: 'client/templates/*.jade', | |
dest: 'build/html' | |
}, | |
scripts: { | |
src: 'client/assets/js/**/*.js', | |
dest: 'build/assets/js' | |
}, | |
styles: { | |
src: 'client/assets/css/**/*.scss', | |
dest: 'build/assets/css' | |
}, | |
images: { | |
src: 'client/assets/img/**/*', | |
dest: 'build/assets/img' | |
} | |
}; | |
gulp.task('templates', function() { | |
return gulp.src(paths.templates.src) | |
.pipe(jade()) | |
.pipe(gulp.dest(paths.templates.dest)) | |
}); | |
gulp.task('scripts', function() { | |
// Minify and copy all JavaScript (except vendor scripts) | |
return gulp.src(paths.scripts.src) | |
.pipe(uglify()) | |
.pipe(concat('all.min.js')) | |
.pipe(gulp.dest(paths.scripts.dest)); | |
}); | |
gulp.task('styles', function () { | |
return gulp.src(paths.styles.src) | |
.pipe(plumber()) | |
.pipe(sass()) | |
.pipe(gulp.dest(paths.styles.dest)); | |
}); | |
// Copy all static images | |
gulp.task('images', function() { | |
return gulp.src(paths.images.src) | |
// Pass in options to the task | |
.pipe(imagemin({optimizationLevel: 5})) | |
.pipe(gulp.dest(paths.images.dest)); | |
}); | |
// Rerun the task when a file changes | |
gulp.task('watch', function() { | |
gulp.watch(paths.templates.src, ['templates']); | |
gulp.watch(paths.scripts.src, ['scripts']); | |
gulp.watch(paths.styles.src, ['styles']); | |
gulp.watch(paths.images.src, ['images']); | |
}); | |
// The default task (called when you run `gulp` from cli) | |
gulp.task('default', ['templates', 'scripts', 'styles', 'images', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment