Skip to content

Instantly share code, notes, and snippets.

@nivv
Created June 26, 2014 08:03
Show Gist options
  • Save nivv/f22c517ceb07fccfe915 to your computer and use it in GitHub Desktop.
Save nivv/f22c517ceb07fccfe915 to your computer and use it in GitHub Desktop.
//Module install command: npm install gulp-less gulp-livereload gulp-imagemin gulp-uglify gulp-minify-css gulp-rename gulp-notify --save
// Get modules
var gulp = require('gulp');
// Task boilerplate
gulp.task('taskname', function() {
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['']);
// Get modules
var gulp = require('gulp');
var less = require('gulp-less');
var livereload = require('gulp-livereload');
var imagemin = require('gulp-imagemin');
var uglify = require('gulp-uglify');
var minify_css = require('gulp-minify-css');
var rename = require('gulp-rename');
var notify = require("gulp-notify");
// Task less
gulp.task('styles', function () {
gulp.src('less/bootstrap.less')
.pipe(less(function () {
this.emit("error", new Error("Something happend: Error message!"))
}))
.on("error", notify.onError(function (error) {
return "Message to the notifier: " + error.message;
}))
.pipe(minify_css())
.pipe(rename('style.min.css'))
.pipe(gulp.dest('css'))
.pipe(livereload());
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['less']);
gulp.task('images', function () {
gulp.src('images-orig/*.{png,gif,jpg}/')
.pipe(imagemin())
.pipe(gulp.dest('images/'));
});
gulp.task('watch', function () {
var server = livereload();
gulp.watch('less/*.less', ['styles']);
gulp.watch('js/**.js', ['scripts']);
gulp.watch('images-orig/**', ['images']);
gulp.watch('../../app/views/**/*.php').on('change', function(file) {
server.changed(file.path);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment