Skip to content

Instantly share code, notes, and snippets.

View tterb's full-sized avatar
Building stuff

Brett Stevenson tterb

Building stuff
View GitHub Profile
@tterb
tterb / blacklist.exact.json
Last active October 23, 2023 02:55
PiHole blacklist
/**
* Supplementary blacklist for PiHole
* Improves coverage on https://d3ward.github.io/toolz/adblock.html
**/
[
{
"id": 3,
"type": 1,
"domain": "adtech.yahooinc.com",
@tterb
tterb / Gulpfile-pt8.js
Created December 20, 2019 08:00
Gulpfile clean
// Delete CSS
gulp.task('clean:styles', function(callback) {
del([paths.jekyllCssFiles + 'main.css',
paths.siteCssFiles + 'main.css',
'_includes/critical.css'
]);
callback();
});
// Delete processed JS
@tterb
tterb / Gulpfile-pt7.js
Created December 20, 2019 07:59
Jekyll build
// Run jekyll build command.
gulp.task('build:jekyll', function() {
var shellCommand = 'bundle exec jekyll build --config _config.yml';
return gulp.src('')
.pipe(run(shellCommand))
.on('error', gutil.log);
});
// Special tasks for building and reloading BrowserSync
gulp.task('build:jekyll:watch', ['build:jekyll:local'], function(callback) {
@tterb
tterb / Gulpfile-pt6.js
Created December 20, 2019 07:58
Gulpfile fonts
// Place fonts in proper location
gulp.task('build:fonts', function() {
return gulp.src(paths.fontFiles + '/**/**.*')
.pipe(rename(function(path) {path.dirname = '';}))
.pipe(gulp.dest(paths.jekyllFontFiles))
.pipe(gulp.dest(paths.siteFontFiles))
.pipe(browserSync.stream())
.on('error', gutil.log);
});
@tterb
tterb / Gulpfile-pt5.js
Last active December 20, 2019 07:32
Gulpfile images
// Optimize and copy image files
gulp.task('build:images', function() {
return gulp.src(paths.imageFilesGlob)
.pipe(imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true,
use: [pngquant()]
}))
.pipe(gulp.dest(paths.jekyllImageFiles))
@tterb
tterb / Gulpfile-pt4.js
Last active September 25, 2020 17:39
Gulpfile scripts
// Concatenate and uglify global JS files and output the result to the
// appropriate location
gulp.task('build:scripts:global', function() {
return gulp.src([
paths.jsFiles + '/lib' + paths.jsPattern,
paths.jsFiles + '/*.js'
])
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(gulp.dest(paths.jekyllJsFiles))
@tterb
tterb / Gulpfile-pt3.js
Created December 20, 2019 07:16
Gulpfile critical
// Create and process critical CSS file to be included in head
gulp.task('build:styles:critical', function() {
return sass(paths.sassFiles + '/critical.scss', {
style: 'compressed',
trace: true,
loadPath: [paths.sassFiles]
}).pipe(postcss([ autoprefixer({ browsers: ['last 2 versions'] }), cssnano()]))
.pipe(gulp.dest('_includes'))
.on('error', gutil.log);
});
@tterb
tterb / Gulpfile-pt2.js
Created December 20, 2019 07:12
Gulpfile stylesheets
// Process styles, add vendor-prefixes, minify, then
// output the file to the appropriate location
gulp.task('build:styles:main', () => {
return sass(paths.sassFiles + '/main.scss', {
style: 'compressed',
trace: true,
loadPath: [paths.sassFiles]
}).pipe(postcss([autoprefixer({ browsers: ['last 2 versions']}), cssnano()]))
.pipe(gulp.dest(paths.jekyllCssFiles))
.pipe(gulp.dest(paths.siteCssFiles))
@tterb
tterb / Gulpfile.js
Created December 20, 2019 07:01
Jekyll Gulpfile
// Gulpfile.js
const autoprefixer = require('autoprefixer');
const browserSync = require('browser-sync').create();
const concat = require('gulp-concat');
const cssnano = require('cssnano');
const del = require('del');
const gulp = require('gulp');
const gutil = require('gulp-util');
const imagemin = require('gulp-imagemin');
const pngquant = require('imagemin-pngquant');
@tterb
tterb / paths.js
Last active September 25, 2020 17:34
Jekyll paths
var paths = {};
// Directory locations.
paths.assetsDir = '_assets/'; // The files Gulp will handle.
paths.jekyllDir = ''; // The files Jekyll will handle.
paths.jekyllAssetsDir = 'assets/'; // The asset files Jekyll will handle.
paths.siteDir = '_site/'; // The resulting static site.
paths.siteAssetsDir = '_site/assets/'; // The resulting static site's assets.
// Folder naming conventions.
paths.postFolder = '_posts';