diff --git a/TODO.taskpaper b/TODO.taskpaper index ad00228..3abf19f 100644 --- a/TODO.taskpaper +++ b/TODO.taskpaper @@ -32,6 +32,8 @@ General tasks: - Main CSS file. - That’s about all I have control over! @done(2016-07-09) - Figure out a workflow for getting from a source image (in Sketch?) to optimised assets for the web site. +- Remove unused CSS to slim down the site a bit. + Doing something like this: https://hellojason.net/blog/remove-unused-css-from-middleman-before-deploying/ in an `after_build` step might work. Port articles across from Medium: - Mental Wellbeing App Survey: https://blog.woss.name/mental-wellbeing-app-survey-54fd3f572e86#.l246uyxgn diff --git a/gulpfile.coffee b/gulpfile.coffee index ae1cca6..fd46dbd 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -6,6 +6,7 @@ less = require 'gulp-less' autoprefixer = require 'gulp-autoprefixer' sourcemaps = require 'gulp-sourcemaps' minifyCSS = require 'gulp-minify-css' +uncss = require 'gulp-uncss' uglify = require 'gulp-uglify' rollbar = require 'gulp-rollbar' @@ -110,3 +111,8 @@ gulp.task 'watch', -> gulp.watch [ paths.less ].concat(watchedLessPaths), [ 'build:stylesheets:development' ] gulp.watch paths.javascripts, [ 'build:javascripts:development' ] gulp.watch paths.fonts, [ 'build:fonts' ] + +gulp.task 'uncss', -> + gulp.src(path.join(paths.dist.stylesheets, '**', '*.css')) + .pipe(uncss(html: path.join('build', '**', '*.html'))) + .pipe(gulp.dest(paths.dist.stylesheets)) diff --git a/package.json b/package.json index b472cfc..16944d7 100644 --- a/package.json +++ b/package.json @@ -38,5 +38,8 @@ }, "engines": { "node": "^6.2.1" + }, + "dependencies": { + "gulp-uncss": "^1.0.5" } }