Closed ltvan closed 8 years ago
Sorry, it seems that I miss the option.extra
. It does the work.
@ltvan @tschaub In my case it does not work
gulp.src('src/public/less/main.less')
.pipe(newer({
dest: 'dest/public/css/main.css',
extra: 'src/public/less/**'
}))
.pipe(less())
.pipe(gulp.dest('./dist/public/css/'))
After each run gulp, he rebuilds main.less
You compare with wrong file: dist
vs dest
.
@ltvan @tschaub No, my original gulpfile.js
is correct, error only in this snippet.
But I found error.
For example you have follow file structure
src/main.less
src/variables/colors.less
dest/
For example, you changed main.less
at 00:00, and run gulp
at 00:01, they build source to dest/
. Mtime for dest/main.css
will be not 00:01, it will be 00:00, because gulp.dest
copy mtime of main.less
.
And now, if you change colors.less
at 00:02, and run gulp
, gulp will compile source, because mtime of main.css
- 00:00 is smaller than mtime of colors.less
- 00:02. And if you run gulp
again, it will compile sources again, because mtime of main.css
- 00:00 is smaller than mtime of colors.less
- 00:02 .
But, you can resolve error using gulp-touch
,
gulp.src('src/main.less')
.pipe(newer({
extra: [
'src/variables/*.less'
],
dest: 'dest/main.css'
}))
.pipe(less())
.pipe(gulp.dest('dist/'))
.pipe(touch())
Now, mtime of main.css
will be bigger than mtime of main.less
Not sure why you get this error, because in my case, the mtime of css file is always the latest at time of gulp run:
return gulp.src(paths.lessFiles)
.pipe(plumber(done))
.pipe(newer({ dest: paths.lessDest, ext: '.min.css', extra: paths.lessWatchFiles }))
.pipe(less())
.pipe(autoprefixer('last 2 version'))
.pipe(gulpif(release, cleanCss()))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(paths.lessDest))
I recently come to same issue as #16, but my suggestion is a litte bit different. It should have an option so that
gulp-newer
can check a different file set like this: