Skip to content

Commit

Permalink
fix: compatible with the changes of @fullhuman/postcss-purgecss v7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Nov 24, 2024
1 parent 28c61c7 commit 4b717eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion assets/hb/purgecss.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
let purgeCSSPlugin = requireX('@fullhuman/postcss-purgecss')
const stats = './hugo_stats.json'
const path = require('path')
const fs = require('fs')
Expand Down Expand Up @@ -35,7 +36,12 @@ try {
throw new Error(`Failed to parse runtime PurgeCSS config.\nPlease enable the "--renderToDisk" if you are using Hugo server.\n${err}`)
}

const purgecss = requireX('@fullhuman/postcss-purgecss')({
if (typeof purgeCSSPlugin !== 'function') {
// Compatible with v7.0.0.
console.error(111)
purgeCSSPlugin = purgeCSSPlugin.purgeCSSPlugin
}
const purgecss = purgeCSSPlugin({
content: [stats],
defaultExtractor: (content) => {
let els = JSON.parse(content).htmlElements
Expand Down

0 comments on commit 4b717eb

Please sign in to comment.