L
L
luleboca2017-01-18 16:07:48
gulp.js
luleboca, 2017-01-18 16:07:48

How to specify the same path in gulp-newer as the file from src?

I'm trying to make a task that checks if the file with the extension has been .source.jschanged, and if so, then we minimize it, change the extension to .jsand put it in the same folder as the source. .source.js
It turns out two files: script.source.js and the minified script.js

gulp.task('minify', () => {
  return gulp.src('../js/**/*.source.js', {since: gulp.lastRun('minify')})
    .pipe(newer()) // как сюда прописать dest файла?
    .pipe(uglify())
    .pipe(extension('.js', '.source.js'))
    .pipe(gulp.dest((file) => {
      return file.base;
    }));
});

Also tried to do this:
gulp.task('minify', () => {
  return gulp.src('../js/**/*.source.js', {since: gulp.lastRun('minify')})
    .pipe(newer('../js/'))
    .pipe(uglify())
    .pipe(extension('.js', '.source.js'))
    .pipe(gulp.dest('../js/'));
});

In this variant, gulp-newer does not see changed files at all.
There is a parameter in the config options.ext
If you explicitly specify the file extension: .pipe(newer('../js/', {ext: '.js'})), then one hell of a change is not visible ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
luleboca, 2017-01-19
@luleboca

Understood.
Debug file

.on('data', (file) => {
  console.log('ext:', file.extname);
})

It turns out there is no such extension .source.js. The file is always treated as .js
So gulp-newer didn't work properly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question