less - gulp-changed with gulp-concat not working -
i want compile .less files have changed in order speed debug/coding workflow.
here gulp task:
gulp.src('core/**/*.less') .pipe(changed('core')) .pipe(less().on('error', handleerror)) .pipe(autoprefixer('last 2 version')) .pipe(remember()) .pipe(concat('main.min.css')) .pipe(gulp.dest('core')) .on('end', resolve) .on('error', reject); i used gulp-changed , because didn't work @ first, tried use gulp-remember well, no effect. watch works, compiles super fast, has no effect @ all.
if remove changed('core') , remember() works, it's slower (around 16 seconds).
gulp-changed poor fit use case, since meant compare input files output files on disk.
say have input file core/foo/bar.less pipe through changed('dist'). output file dist/foo/bar.less. if input file newer output file, passed through. otherwise filtered out.
that means using changed('core') cannot possibly work. compares input file core/foo/bar.less output file core/foo/bar.less. but they're same file. means input file can never newer output file , never passed through.
there's problem. don't have 1 output file each input file. .less files compiled one main.min.css file. while can make work using custom comparator doesn't work out of box.
what want gulp-cached. instead of comparing each input file output file on disk compares each input file previous version of same file has been cached in memory.
var cached = require('gulp-cached'); gulp.task('css', function() { return gulp.src('core/**/*.less') .pipe(cached('less')) .pipe(less()) .pipe(autoprefixer('last 2 version')) .pipe(remember('less')) .pipe(concat('main.min.css')) .pipe(gulp.dest('core')); });
Comments
Post a Comment