F
F
freestm2017-06-22 13:30:44
Web development
freestm, 2017-06-22 13:30:44

How to make gulp compress only uncompressed files?

there is such a task

gulp.task('libs', function () {
  gulp.src('./src/libs/css/**/*.css')
  .pipe(cssnano())
  .pipe(rename({suffix: '.min'}))
  .pipe(gulp.dest(dest_path + '/css'))
  .pipe(browserSync.reload({stream: true}))
  gulp.src('./src/libs/js/**/*.js')
  .pipe(uglify())
  .pipe(rename({suffix: '.min'})) 
  .pipe(gulp.dest(dest_path + '/js'))
  .pipe(browserSync.reload({stream: true}))
});

The problem is that if there are already compressed files in the libs folder, gulp still tries to compress them and assigns the min suffix. The output is jquery-3.2.1.min.min.js...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Zhivagin, 2017-06-22
@Krasnodar_etc

gulp.src('./src/libs/js/**/*.js', '!./src/libs/js/**/*.min.js')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question