gulpfile.js
var gulp = require('gulp')
,imagemin = require('gulp-imagemin');
gulp.task('build-img', function() {
gulp.src('src/img/**/*')
.pipe(imagemin())
.pipe(gulp.dest('src/img'));
});
resultado:
C:\Users\andre\Documents\estudo\Alura Gulp [Engenheiro Front End]\projeto>npm run gulp build-img
> projeto@1.0.0 gulp C:\Users\andre\Documents\estudo\Alura Gulp [Engenheiro Front End]\projeto
> gulp "build-img"
[00:59:05] Using gulpfile ~\Documents\estudo\Alura Gulp [Engenheiro Front End]\projeto\gulpfile.js
[00:59:05] Starting 'build-img'...
[00:59:05] Finished 'build-img' after 21 ms
[00:59:05] gulp-imagemin: Minified 0 images
package.json
{
"name": "projeto",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"dependencies": {
"gulp-imagemin": "^2.3.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gulp" : "gulp"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^3.9.0",
"gulp-imagemin": "^2.3.0"
}
}