diff --git a/gulpconfig.json b/gulpconfig.json index 2280ad8..14bdd59 100644 --- a/gulpconfig.json +++ b/gulpconfig.json @@ -11,6 +11,8 @@ "paths" : { "js": "./js", "css": "./css", + "img": "./img", + "imgsrc": "./src/img", "sass": "./sass", "node": "./node_modules/", "bower": "./bower_components/", diff --git a/gulpfile.js b/gulpfile.js index 6cd8262..ee35432 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -101,16 +101,25 @@ gulp.task('watch', function () { gulp.watch([paths.dev + '/js/**/*.js','js/**/*.js','!js/theme.js','!js/theme.min.js'], ['scripts']); //Inside the watch task. - gulp.watch('./img/**', ['imagemin']) + gulp.watch(paths.imgsrc + '/**', ['imagemin-watch']); +}); + +/** + * Ensures the 'imagemin' task is complete before reloading browsers + * @verbose + */ +gulp.task('imagemin-watch', ['imagemin'], function(done) { + browserSync.reload(); + done(); }); // Run: // gulp imagemin // Running image optimizing task gulp.task('imagemin', function(){ - gulp.src('img/src/**') + gulp.src(paths.imgsrc + '/**') .pipe(imagemin()) - .pipe(gulp.dest('img')) + .pipe(gulp.dest(paths.img)) });