Skip to content

Commit

Permalink
update image tasks and exclude lazload classes from css clean
Browse files Browse the repository at this point in the history
  • Loading branch information
nathakits committed Jun 1, 2017
1 parent 2cca3ab commit cb9e5f9
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions gulpfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ webp = require 'gulp-webp'
size = require 'gulp-size'
rename = require 'gulp-rename'
imagemin = require 'gulp-imagemin'
imgResize = require 'gulp-image-resize'

# =================================================================
# high level tasks
Expand All @@ -47,8 +48,9 @@ gulp.task "build", (cb)->

gulp.task "preview", (cb)->
return runSequence ['build:clean', 'js:clean'],
['css:build','js:build','img:make:previews'],
['css:build','js:build'],
'build_wintersmith',
'webp:make',
'css:clean',
cb

Expand Down Expand Up @@ -199,6 +201,26 @@ gulp.task 'image_min', ->
# lazyload & webp tasks
# =================================================================

gulp.task "img:make", (cb)->
return runSequence 'webp:make',
'img:make:previews'
cb

gulp.task "img:clean", (cb)->
return runSequence 'jpeg:format',
'jpeg:clean'
cb

gulp.task "jpeg:clean", ->
return gulp.src('contents/media/images/**/*.{jpeg}',{read:false})
.pipe(clean())

gulp.task "jpeg:format", ->
return gulp.src('contents/media/images/**/*.{jpeg}',{base: './'})
.pipe plumber()
.pipe imgResize({format: 'jpg'})
.pipe(gulp.dest('./'))

gulp.task 'img:make:previews', ->
options = {
resize: [20,20],
Expand All @@ -209,15 +231,15 @@ gulp.task 'img:make:previews', ->
trellisQuantisation: false
}

return gulp.src('build/media/images/**/*.{jpg,png}',{base: './'})
return gulp.src('./build/media/images/**/*.{jpg,png}',{base: './'})
.pipe(plumber())
.pipe(image_min(options))
.pipe rename
suffix: '_preview'
.pipe(gulp.dest('./'))

gulp.task 'webp:make', ->
return gulp.src('contents/media/images/**/*.{jpg,png}',{base: './'})
return gulp.src('./build/media/images/**/*.{jpg,png}',{base: './'})
.pipe plumber()
.pipe size()
.pipe webp
Expand Down Expand Up @@ -363,6 +385,8 @@ gulp.task "css:clean", ->
new RegExp('^.parsley-.*')
new RegExp('^.datalist.*')
new RegExp('^li.active.*')
new RegExp('^.lazyloaded.*')
new RegExp('^.img-large--webp.*')
]
))
.pipe(gulp.dest('build/css'))

0 comments on commit cb9e5f9

Please sign in to comment.