Created
January 6, 2015 13:31
-
-
Save hardikpandya/09c515fd43c9f0559857 to your computer and use it in GitHub Desktop.
Gulp.js
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 concat = require('gulp-concat'); | |
var rename = require('gulp-rename'); | |
var uglify = require('gulp-uglify'); | |
var minifyCSS = require('gulp-minify-css'); | |
var imagemin = require('gulp-imagemin'); | |
var pngquant = require('imagemin-pngquant'); | |
var notify = require('gulp-notify'); | |
gulp.task('css-js', function() { | |
return gulp.src('js/*.js') // read all of the files that are in script/lib with a .js extension | |
.pipe(concat('js/all.js')) // concatenate all of the file contents into a file titled 'all.js' | |
.pipe(gulp.dest('./')) // write that file to the dist/js directory | |
.pipe(rename('all.min.js')) // now rename the file in memory to 'all.min.js' | |
.pipe(uglify()) // run uglify (for minification) on 'all.min.js' | |
.pipe(gulp.dest('js/')) | |
return gulp.src('css/*.css') | |
.pipe(concat('css/style.css')) | |
.pipe(gulp.dest('./')) | |
.pipe(minifyCSS()) | |
.pipe(rename('style.min.css')) | |
.pipe(gulp.dest('css/')); | |
// write all.min.js to the dist/js file | |
}); | |
gulp.task('images', function () { | |
return gulp.src('images/*.*') | |
.pipe(imagemin({ optimizationLevel: 2, progressive: true, interlaced: true })) | |
.pipe(gulp.dest('images/')) | |
.pipe(notify({ message: 'Images task complete' })); | |
}); | |
gulp.task('watch', function() { | |
// Watch .js files | |
gulp.watch('js/*.js', ['default']); | |
// Watch .scss files | |
gulp.watch('css/*.css', ['default']); | |
}); | |
gulp.task('default', ['css-js', 'images']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment