Skip to content

Instantly share code, notes, and snippets.

@KruegerDesigns
Last active August 29, 2015 14:15
Show Gist options
  • Save KruegerDesigns/3bc04b773b9c89405170 to your computer and use it in GitHub Desktop.
Save KruegerDesigns/3bc04b773b9c89405170 to your computer and use it in GitHub Desktop.
Start processing less files with this Gulp file! Also supports minified CSS and LiveReload watching.
// Run "npm init" and fill out the wizard
// Then run the following to install all dependancies:
// npm install gulp gulp-util gulp-plumber gulp-less gulp-cssmin gulp-concat gulp-rename gulp-livereload
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var gutil = require('gulp-util');
var plumber = require('gulp-plumber');
var less = require('gulp-less');
var cssmin = require('gulp-cssmin');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var livereload = require('gulp-livereload');
// LESS css task
gulp.task('less', function() {
return gulp.src('assets/stylesheets/style.less') // only compile the entry file
.pipe(plumber(function(error) {
gutil.log(gutil.colors.red(error.message));
gutil.beep();
this.emit('end');
}))
.pipe(less({
paths: ['assets/stylesheets/']
}))
.pipe(rename('layout.css'))
.pipe(gulp.dest('assets/stylesheets/'))
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))//
.pipe(gulp.dest('assets/stylesheets/'));
});
// Watch Files For Changes
gulp.task('watch', function() {
gulp.watch('assets/stylesheets/*.less', ['less']);
livereload.listen();
gulp.watch('assets/stylesheets/*').on('change', livereload.changed);
gulp.watch('*').on('change', livereload.changed);
});
// Default Task
gulp.task('default', ['less', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment