Skip to content

Instantly share code, notes, and snippets.

View danklammer's full-sized avatar

Dan Klammer danklammer

View GitHub Profile
@danklammer
danklammer / .eleventy.config.js
Created October 16, 2020 15:00 — forked from danielpost/.eleventy.config.js
Eleventy: Purge CSS for each html file
const { PurgeCSS } = require('purgecss');
/**
* Remove any CSS not used on the page and inline the remaining CSS in the
* <head>.
*
* @see {@link https://github.com/FullHuman/purgecss}
*/
eleventyConfig.addTransform('purge-and-inline-css', async (content, outputPath) => {
if (process.env.ELEVENTY_ENV !== 'production' || !outputPath.endsWith('.html')) {