gulp-community / gulp-less

A LESS plugin for Gulp
559 stars 116 forks source link

Does it support Gulp v4? #311

Closed akanshgulati closed 3 years ago

akanshgulati commented 4 years ago
  1. The README.md file says it supports Gulp 3.x version only.
  2. After updating the version from 3.0.5 to 4.0.1, I found files started giving errors having extension less imports
@import "../../not-imported-less-file"; // terminal giving error that could not find the file when less file has no extension
@import "../../imported-less-file.less";

@stevelacy Please help.

yocontra commented 4 years ago

@akanshgulati Can you post a full example? This library supports any version of gulp - plugins had no breaking changes between 3 and 4. You probably updated one of your other dependencies (like your version of less) that is causing the issue.

cfbauer commented 3 years ago

I was getting signal async completion errors when following the documentation with gulp 4. Here's what I had to do:


gulp.task('styles', function(done) {
  gulp.src('./less/**/*.less')
    .pipe(less({
      paths: [ path.join(__dirname, 'less', 'includes') ]
    }))
    .pipe(gulp.dest('./css'));
  done() // Signal async completion
})
cfbauer commented 3 years ago

Here's my entire gulpfile for getting watching working with gulp 4. I'm new to gulp but it's hard to find documentation for getting gulp-less watching on gulp 4 so hopefully this is helpful:


const { watch, dest, src } = require('gulp');
const less = require('gulp-less');
const path = require('path');

// This is the new way with gulp 4 but there is less documentation for it.

function compile(cb) {
  return src('./less/**/*.less')
    .pipe(less({
      paths: [ path.join(__dirname, 'less', 'includes') ]
    }))
    .pipe(dest('./css'));
  done();
  cb();
}

exports.default = function() {
  watch('./less/**/*.less', compile);
}