From 5da06e3a8792e4d9a6e502da6aac97b28862abd7 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Wed, 2 Feb 2022 00:43:30 -0600 Subject: [PATCH] Add purgecss to css processing workflow --- config.toml | 3 +++ layouts/_default/baseof.html | 2 +- postcss.config.js | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 postcss.config.js diff --git a/config.toml b/config.toml index cc4608e..4989eb1 100644 --- a/config.toml +++ b/config.toml @@ -4,6 +4,9 @@ title = "MillironX" paginate = 5 theme = "ananke" +[build] + writeStats = true + [Params] cardImage = "saddles" motto = "" diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 92591a9..9ef8a4e 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -10,7 +10,7 @@ {{ $twbscss := resources.Get "node/node_modules/bootstrap/scss/bootstrap.scss" | resources.ToCSS }} {{ $mycss := resources.Get "styles/main.css" }} {{ $allcss := slice $twbscss $mycss | resources.Concat "css/bundle.css" }} - {{ $allcsspure := $allcss | resources.PostCSS | minify | fingerprint | resources.PostProcess }} + {{ $allcsspure := $allcss | resources.PostCSS (dict "nomap" true) | minify | fingerprint | resources.PostProcess }} diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..faed436 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,13 @@ +const purgecss = require('@fullhuman/postcss-purgecss')({ + content: ['./hugo_stats.json'], + defaultExtractor: (content) => { + let els = JSON.parse(content).htmlElements; + return els.tags.concat(els.classes, els.ids); + } +}); + +module.exports = { + plugins: [ + purgecss + ] +}