Created
February 10, 2014 15:26
-
-
Save zanmoskotevc/8917845 to your computer and use it in GitHub Desktop.
Gulpy di gulp.
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'), | |
concat = require('gulp-concat'), | |
notify = require('gulp-notify'), | |
imagemin = require('gulp-imagemin'), | |
less = require('gulp-less'), | |
prefixer = require('gulp-autoprefixer'), | |
minify = require('gulp-minify-css'), | |
uglify = require('gulp-uglify'), | |
livereload = require('gulp-livereload'), | |
lr = require('tiny-lr'), | |
server = lr(); | |
gulp.task('img', function() { | |
return gulp.src('public/dev/img/*') | |
.pipe(imagemin({optimizationLevel: 5})) | |
.pipe(gulp.dest('public/dist/img')) | |
.pipe(notify('Gulp: images processed.')); | |
}); | |
gulp.task('css', function() { | |
return gulp.src('public/dev/*.less') | |
.pipe(less()) | |
.pipe(prefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) | |
.pipe(minify()) | |
.pipe(gulp.dest('public/dist/css')) | |
.pipe(livereload(server)) | |
.pipe(notify('Gulp: CSS processed.')); | |
}); | |
gulp.task('js', function() { | |
return gulp.src('public/dev/*.js') | |
.pipe(concat('main.js')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('public/dist/js')) | |
.pipe(livereload(server)) | |
.pipe(notify('Gulp: js processed.')); | |
}); | |
gulp.task('watch', function () { | |
// Watch for images | |
gulp.watch('public/dev/img/**/*', ['img']); | |
server.listen(35729, function (err) { | |
if (err) return console.log(err); | |
// Watch for *.less files | |
gulp.watch('public/dev/*.less', ['css']); | |
// Watch for *.js files | |
gulp.watch('public/dev/*.js', ['js']); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment