Skip to content

Commit 51a9724

Browse files
author
Donovan Hutchinson
committed
Adding images support
1 parent 5fef99c commit 51a9724

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

gulpfile.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ var gulp = require('gulp'),
1212
plumber = require('gulp-plumber'),
1313
browserSync = require('browser-sync'),
1414
cssshrink = require('gulp-cssshrink'),
15-
cp = require('child_process');
15+
cp = require('child_process'),
16+
changed = require('gulp-changed'),
17+
imagemin = require('gulp-imagemin'),
18+
size = require('gulp-size');
1619

1720

1821
gulp.task('styles', function() {
@@ -40,6 +43,20 @@ gulp.task('scripts', function() {
4043
.pipe(browserSync.reload({stream:true}));
4144
});
4245

46+
// Optimizes the images that exists
47+
gulp.task('images', function () {
48+
return gulp.src('src/images/**')
49+
.pipe(changed('public/images'))
50+
.pipe(imagemin({
51+
// Lossless conversion to progressive JPGs
52+
progressive: true,
53+
// Interlace GIFs for progressive rendering
54+
interlaced: true
55+
}))
56+
.pipe(gulp.dest('public/images'))
57+
.pipe(size({title: 'images'}));
58+
});
59+
4360
gulp.task('browser-sync', ['styles', 'scripts'], function() {
4461
browserSync({
4562
server: {
@@ -56,8 +73,10 @@ gulp.task('watch', function() {
5673
gulp.watch('src/sass/**/*.scss', ['styles', browserSync.reload]);
5774
// Watch .js files
5875
gulp.watch('src/javascripts/*.js', ['scripts', browserSync.reload]);
76+
// Watch image files
77+
gulp.watch('src/images/**/*', ['images', browserSync.reload]);
5978
});
6079

6180
gulp.task('default', function() {
62-
gulp.start('styles', 'scripts', 'browser-sync', 'watch');
81+
gulp.start('styles', 'scripts', 'images', 'browser-sync', 'watch');
6382
});

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@
1212
},
1313
"devDependencies": {
1414
"browser-sync": "^1.9.1",
15+
"del": "^1.1.1",
1516
"gulp": "^3.8.7",
1617
"gulp-autoprefixer": "0.0.8",
1718
"gulp-cache": "^0.2.0",
18-
"del": "^1.1.1",
19+
"gulp-changed": "^1.2.1",
1920
"gulp-concat": "^2.3.4",
2021
"gulp-cssshrink": "^0.1.4",
22+
"gulp-imagemin": "^2.2.1",
2123
"gulp-jshint": "^1.8.3",
2224
"gulp-minify-css": "^0.3.13",
2325
"gulp-notify": "^1.8.0",
2426
"gulp-plumber": "^0.6.4",
2527
"gulp-rename": "^1.2.0",
2628
"gulp-sass": "^2.0.1",
29+
"gulp-size": "^1.2.1",
2730
"gulp-uglify": "^0.3.2"
2831
}
2932
}

src/images/rocky.png

57 KB
Loading

0 commit comments

Comments
 (0)