Jekyll, reddit

My super simple gulpfile for Jekyll + – It also compiles all SCSS files with correct sourcemaps, works like a charm. 2019-05-15 06:47:03

Might be helpful for someone. You don't need to use forestry for this to work, but it's seamless with their system. Modified from this gulpfile here:

Of course you could get a little more crazy with this. I'll be adding all the npm package goodies later on. I just had a little trouble getting gulp to play nice with Jekyll and Forestry, so figured I'd share.

Most important piece is the gulp-touch package– otherwise Jekyll wont regenerate unless you save the primary scss file with your imports.

var gulp = require('gulp'); var shell = require('gulp-shell'); var sass = require('gulp-sass'); var sourcemaps = require('gulp-sourcemaps'); // Gulp-touch adds a timestamp to the main.css file, so Jekyll knows to regenerate the site var touch = require('gulp-touch-cmd'); gulp.task('generate', shell.task('bundle exec jekyll serve --watch --livereload -o')); gulp.task('buildit', shell.task('bundle exec jekyll build -d _site')); gulp.task('styles', function () { return gulp.src('./assets/css/main.scss') .pipe(sourcemaps.init({loadMaps: true})) .pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError)) .pipe(sourcemaps.write('.')) .pipe(gulp.dest('css/')) .pipe(touch()); }); // Deploy task on gulp.task('deploy', gulp.series( 'styles', 'buildit' )); // Watch scss changes gulp.task('watch', function() {'assets/**/*.scss', gulp.series('styles')); }); // Default: watch and build local gulp.task('default', gulp.parallel( 'watch', 'generate' )); 
submitted by /u/Mike
[link] [comments]

Read more