Created
June 17, 2020 23:41
-
-
Save nickstewart95/9521f0f5054ace42859a889ead813cfc to your computer and use it in GitHub Desktop.
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'); | |
var sass = require('gulp-sass'); | |
var livereload = require('gulp-livereload'); | |
var inlineCss = require('gulp-inline-css'); | |
var replace = require('gulp-replace'); | |
var fs = require('fs'); | |
sass.compiler = require('node-sass'); | |
gulp.task('sass', function () { | |
return gulp.src('./res/sass/*.scss') | |
.pipe(sass().on('error', sass.logError)) | |
.pipe(gulp.dest('./res/build')) | |
.pipe(livereload()); | |
}); | |
gulp.task('watch', function() { | |
livereload.listen(); | |
gulp.watch('./res/sass/*.scss', gulp.series('build')); | |
gulp.watch('./index.html', gulp.series('build')); | |
}); | |
gulp.task('inline', function() { | |
return gulp.src('./*.html') | |
.pipe(inlineCss({ | |
applyWidthAttributes: true, | |
applyTableAttributes: true, | |
removeHtmlSelectors: true, | |
removeLinkTags: true | |
})) | |
.pipe(replace('%FONT-FACE%', function(s) { | |
var tmpl = fs.readFileSync('font-face.html', 'utf8'); | |
return tmpl; | |
})) | |
.pipe(gulp.dest('build/')); | |
}); | |
gulp.task('default', gulp.series('watch')); | |
gulp.task('build', gulp.series('sass', 'inline')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment