Ao executar o comando npm run gulp se obtem o retorno abaixo:
λ npm run gulp
> projeto@1.0.0 gulp C:\Users\Jeiel\Dropbox\Documents\Programing\alura\gulp\01-capitulo\projeto
> gulp
[23:08:51] Using gulpfile ~\Dropbox\Documents\Programing\alura\gulp\01-capitulo\projeto\gulpfile.js
[23:08:51] Starting 'clean'...
[23:08:51] Finished 'clean' after 54 ms
[23:08:51] Starting 'copy'...
[23:08:51] Finished 'copy' after 165 ms
[23:08:51] Starting 'default'...
[23:08:51] Starting 'clean'...
[23:08:51] Starting 'build-js'...
[23:08:51] Finished 'build-js' after 7.75 ms
[23:08:51] Finished 'default' after 14 ms
events.js:160
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open 'C:\Users\Jeiel\Dropbox\Documents\Programing\alura\gulp\01-capitulo\projeto\dist\js\home.js'
at Error (native)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! projeto@1.0.0 gulp: `gulp`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the projeto@1.0.0 gulp script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Jeiel\AppData\Roaming\npm-cache\_logs\2017-09-26T02_08_52_005Z-debug.log
Código:
// gulpfile.js
var gulp = require('gulp'),
imagemin = require('gulp-imagemin'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
htmlReplace = require('gulp-html-replace');
gulp.task('build-img', ['copy'],function() {
// linha quebrada para ajudar na leitura
gulp.src('dist/img/**/*')
.pipe(imagemin())
.pipe(gulp.dest('dist/img'));
});
gulp.task('default', ['copy'],function(){
gulp.start('build-img','build-js','build-html')
})
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-js' ,function() {
// linha quebrada para ajudar na leitura 'dist/js/**/*.js'
gulp.src(['dist/js/jquery.js','dist/js/home.js','dist/js/produto.js'])
.pipe(concat('all.js'))
.pipe(gulp.dest('dist/js'));
});
gulp.task('build-html' ,function() {
// linha quebrada para ajudar na leitura
gulp.src('dist/**/*.html')
.pipe(htmlReplace({js:'js/all.js'}))
.pipe(gulp.dest('dist'));
});