Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.