Y
Y
You can just Eugene2017-07-04 10:43:56
gulp.js
You can just Eugene, 2017-07-04 10:43:56

Deleting files in Gulp?

The question is this:
I have a distribution kit dist/ in it, for example, under the folders assets/images/ , assets/css/ , assets/js/ and others.
How can I do something to delete everything except dist/assets/images/ and everything inside it ?
Tried in different ways ['dist/**' , '!dist/assets/images/'] and nothing happens, it completely deletes the dist/ folder and everything
PS I would not want to register all the folders manually ... (dist/assets /css , dist/assets/js).
Thank you for your attention !!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Shirokuiu, 2017-07-08
@Shirokuiu

Usually, after running the task - gulp build, it cleans the dist folder itself and then puts new files there again. If this option suits you, then here is an example:

var del = require('del')                 // плагин для gulp 'del'

gulp.task('clean', function() {      // сам таск удаления 
  del.sync('dist');    
});

gulp.task('build', ['clean', 'compress', 'cssmin', 'images'], function() {       // таск сборки 
  var buildFonts = gulp.src('app/fonts/**/*')
  .pipe(gulp.dest('dist/fonts'));
  var buildHtml = gulp.src('app/*.html')
  .pipe(gulp.dest('dist'));
});

A
abasiuk, 2018-01-11
@abasiuk

'!dist/assets/images/**/*.*'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question