Answer the question
In order to leave comments, you need to log in
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
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'));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question