Last active
August 29, 2015 14:16
-
-
Save prdolmos/cc5bcb67610acc04cdbd to your computer and use it in GitHub Desktop.
Email processing Gulp config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require("gulp"), | |
slim = require("gulp-slim"), | |
concatCss = require('gulp-concat-css'), | |
uncss = require('gulp-uncss'), | |
stripCssComments = require('gulp-strip-css-comments'), | |
processhtml = require('gulp-processhtml'), | |
smoosher = require('gulp-smoosher'), | |
premailer = require('gulp-premailer'), | |
htmlmin = require('gulp-htmlmin'), | |
jpegoptim = require('imagemin-jpegoptim'), | |
pngquant = require('imagemin-pngquant'), | |
optipng = require('imagemin-optipng'); | |
gulp.task('slim', function(){ | |
var stream = gulp.src("./src/*.slim") | |
.pipe(slim({ | |
pretty: true, | |
format: 'xhtml' | |
})) | |
.pipe(gulp.dest("./src/")); | |
return stream; | |
}); | |
gulp.task('css', ['slim'], function() { | |
var stream = gulp.src("src/css/*.css") | |
.pipe(concatCss("styles.css")) | |
.pipe(uncss({ | |
html: ['src/*.html'] | |
})) | |
.pipe(stripCssComments()) | |
.pipe(gulp.dest('build')); | |
return stream; | |
}); | |
gulp.task('styles', ['css'], function () { | |
gulp.src('src/*.html') | |
.pipe(processhtml()) | |
.pipe(smoosher()) | |
.pipe(gulp.dest('dist')); | |
}); | |
gulp.task('email', ['styles'], function () { | |
gulp.src('dist/*.html') | |
.pipe(premailer()) | |
.pipe(htmlmin({ | |
keepClosingSlash: true, | |
collapseWhitespace: true, | |
preserveLineBreaks: true, | |
removeComments: true | |
})) | |
.pipe(gulp.dest('dist')); | |
}); | |
gulp.task('images', function () { | |
gulp.src('src/images/**/*.{png,jpg,jpeg,gif}') | |
.pipe(pngquant({quality: '65-80', speed: 4})) | |
.pipe(optipng({optimizationLevel: 3})) | |
.pipe(jpegoptim({max: 70})) | |
.pipe(gulp.dest('dist/images')); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch('src/*.slim', ['email']); | |
gulp.watch('src/css/*.css', ['email']); | |
}); | |
gulp.task('default', ['email', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment