Add purgecss to css processing workflow

This commit is contained in:
Thomas A. Christensen II 2022-02-02 00:43:30 -06:00
parent 60bed163e3
commit 5da06e3a87
Signed by: millironx
GPG key ID: 139C07724802BC5D
3 changed files with 17 additions and 1 deletions

View file

@ -4,6 +4,9 @@ title = "MillironX"
paginate = 5 paginate = 5
theme = "ananke" theme = "ananke"
[build]
writeStats = true
[Params] [Params]
cardImage = "saddles" cardImage = "saddles"
motto = "" motto = ""

View file

@ -10,7 +10,7 @@
{{ $twbscss := resources.Get "node/node_modules/bootstrap/scss/bootstrap.scss" | resources.ToCSS }} {{ $twbscss := resources.Get "node/node_modules/bootstrap/scss/bootstrap.scss" | resources.ToCSS }}
{{ $mycss := resources.Get "styles/main.css" }} {{ $mycss := resources.Get "styles/main.css" }}
{{ $allcss := slice $twbscss $mycss | resources.Concat "css/bundle.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 }}
<link href="{{ $allcsspure.Permalink }}" rel="stylesheet"> <link href="{{ $allcsspure.Permalink }}" rel="stylesheet">
</head> </head>

13
postcss.config.js Normal file
View file

@ -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
]
}