Last active
February 3, 2016 22:41
-
-
Save erickolivares/a0cf8ff3efb06a26458a to your computer and use it in GitHub Desktop.
Gulp JS LESS
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 less = require('gulp-less'); | |
var watch = require('gulp-watch'); | |
var minify = require('gulp-minify-css'); | |
var rename = require('gulp-rename'); | |
var header = require('gulp-header'); | |
var pkg = require('./package.json'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
/* Prepare banner text */ | |
var banner = ['/**', | |
' * www.erick-olivares.com v1.0', | |
' * Minified CSS', | |
' * Erick Olivares, [email protected]', | |
' */', | |
''].join('\n'); | |
/* Task to compile less */ | |
gulp.task('compile-less', function() { | |
gulp.src('./wp-content/themes/rez/less/style.less') | |
.pipe(sourcemaps.init()) | |
.pipe(less()) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest('./wp-content/themes/rez/')); | |
}); | |
/* Task to minify css */ | |
gulp.task('minify-css', function() { | |
gulp.src('./wp-content/themes/rez/style.css') | |
.pipe(minify()) | |
.pipe(header(banner, {pkg: pkg})) | |
.pipe(rename('./wp-content/themes/rez/css/style.min.css')) | |
.pipe(gulp.dest( './' )); | |
}); | |
/* Task to watch less changes */ | |
gulp.task('watch-less', function() { | |
gulp.watch('./wp-content/themes/rez/less/**/*.less' , ['compile-less']); | |
}); | |
gulp.task('less', ['compile-less', 'watch-less']); | |
gulp.task('build', ['minify-css']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment