2

I have the following setup:

// watch for changes
gulp.task('watch', function () {
  gulp.watch('./assets/**/*.less', ['compile-less']);
});

gulp.task("compile-less", () => {
    return gulp.src('./assets/build-packages/*.less')
    .pipe($.less({
        paths: [ $.path.join(__dirname, 'less', 'includes') ]
    }))
    .pipe(gulp.dest(OutputPath)); // ./dist/styles/
});

So basically every time a developer changes something in a less file it runs the task 'compile-less'. The task 'compile-less' builds our package less files (including all the @imports). The first change in a random less file works, all the less files are being build. The second time it runs the task but my generated dist folder isn't updated when I change something to a less file that is imported. I'm wondering if the combination of the watch task and the compiling task somehow caches files. Because if I run the compile-less task manually it works everytime.

Does anyone had the same experience?

fabioth
  • 21
  • 3
  • 1
    If it's the latest `gulp-less 4.0.0` then it's just a bug in `less 3.0.*` it uses. See [gulp-less#283](https://github.com/stevelacy/gulp-less/issues/283). – seven-phases-max Mar 07 '18 at 14:05
  • Oh snap, that's exactly what I'm experiencing. Thanks for the link man! – fabioth Mar 07 '18 at 14:17

1 Answers1

4

gulp-less version 4.0.0 has a strange caching issue. Install gulp-less@3.5.0 and will solve the issue. This will be fixed. Check out https://github.com/stevelacy/gulp-less/issues/283#ref-issue-306992692

BananaAcid
  • 3,221
  • 35
  • 38
  • You will also need to install less@2.7.2 since gulp-less v3.5 does not support less v3.0.x. – Derick Apr 08 '18 at 00:21
  • did not have any issues with installing a regular less version, then gulp-less@3.5.0 - anyone knows if it installs an older version into gulp-less/node_modules ? – BananaAcid Apr 08 '18 at 21:14
  • gulp@3.9.1, gulp-less@3.5.0, less@3.0.1 results in 'Error: less version 3.0.1 is not currently supported' – Derick Apr 09 '18 at 21:57