I can't get gulp-less to not process everything, everytime. I've tried:
- updating my version of gulp
- using gulp-changed
- using gulp-newer
It works with gulp-ngmin, but not with gulp-less
So this processes test.js only if I change test.js:
var SRC = 'test.js';
var DEST = 'dist';
gulp.task('test', function () {
return gulp.src(SRC)
.pipe(changed(DEST))
// ngmin will only get the files that
// changed since the last time it was run
.pipe(ngmin())
.pipe(gulp.dest(DEST));
});
But everytime I run this task, it computes the less
What is wrong here?
var SRC = 'test.less';
var DEST = 'dist';
gulp.task('test', function () {
return gulp.src(SRC)
.pipe(changed(DEST))
.pipe(less({
paths: [path.join(__dirname, 'less', 'includes')]
}))
.pipe(gulp.dest(DEST));
});
Actually Nikita's statement is false, it does work and it is it's purpose, just make sure you are setting it up correctly. In my case I have this:
My
gulp.srcpoints to the folder where I have my main LESS files (files which import other LESS files) and I want them all compiled into the destination folder.In
.pipe(changed())you must have the same target as you have in.pipe(gulp.dest()).You can specify the extension to be compared to make it speedier (
{extension: '.css'}) inpipe(changed()).Perhaps you need to double check your
paths: [path.join(__dirname, 'less', 'includes')]. In my case, I just placed there the root folder of all my less files. Some of my LESS files are insrc/less/globalsand others insrc/less/common. The files I want to compile are insrc/less/pages. So I usedsrc/less/pages/*.LESSingulp.src()andsrc/less/in lesspipe(less({paths: []})).