3
I recently started using Gulp in an existing project. I created the following gulpfile.js
:
var gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
htmlReplace = require('gulp-html-replace'),
uglify = require('gulp-uglify'),
usemin = require('gulp-usemin'),
cssmin = require('gulp-cssmin');
gulp.task('default', ['copy'], function(){
gulp.start('build-img', 'usemin');
});
gulp.task('copy', ['clean'], function(){
return gulp.src('src/**/*')
.pipe(gulp.dest('dist'));
});
gulp.task('clean', function(){
return gulp.src('dist')
.pipe(clean());
});
gulp.task('build-img', function(){
gulp.src('dist/img/*/*')
.pipe(imagemin())
.pipe(gulp.dest('dist/img'));
});
gulp.task('usemin', function(){
gulp.src('dist/**/*.html')
.pipe(usemin({
'js' : [uglify],
'css': [cssmin]
}))
.pipe(gulp.dest('dist'));
});
Works correctly, but I would like to know what is the procedure for that in folders dist/css
and dist/js
, all folders and files are deleted and only the files are left index.min.css
and index.min.js
that the usemin()
spawned.
It worked, thank you very much @Allan Andrade
– Gicobbe