Last active
June 2, 2017 04:20
-
-
Save micoli/813fbfa22aa110181951fe97e1c00d18 to your computer and use it in GitHub Desktop.
gulp watch less
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'); | |
var watch = require("gulp-watch"); | |
var less = require('gulp-less'); | |
var path = require('path'); | |
var rename = require('gulp-rename'); | |
var plumber = require('gulp-plumber'); | |
var color = require('gulp-color'); | |
var gutil = require('gulp-util'); | |
var rootPath = './aa/'; | |
gulp.task('watch', function() { | |
return gulp | |
.src(rootPath+'**/*.less') | |
.pipe(watch(rootPath+'**/*.less')) | |
.pipe(plumber()) | |
.pipe(less()) | |
.pipe(rename(function (path) { | |
path.dirname = path.dirname.replace(/less$/,'css'); | |
path.extname = ".css"; | |
gutil.log('saved to '+color(path.dirname,'GREEN')+'/'+color(path.basename,'BLUE')+color(path.extname,'RED')); | |
})) | |
.pipe(gulp.dest('./')); | |
}); | |
gulp.task('default',function(){ | |
gulp.start(['watch']); | |
}) |
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
{ | |
"name": "gulp-less-watcher", | |
"version": "1.0.0", | |
"description": "", | |
"main": "gulpfile.js", | |
"dependencies": { | |
"gulp-plumber": "^1.1.0", | |
"gulp-rename": "^1.2.2", | |
"gulp": "^3.9.1", | |
"gulp-color": "0.0.1", | |
"gulp-less": "^3.3.0", | |
"gulp-plumber": "^1.1.0", | |
"gulp-rename": "^1.2.2", | |
"gulp-util": "^3.0.8", | |
"gulp-watch": "^4.3.11" | |
}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment