Skip to content

Commit

Permalink
fix(purgecss): use process.env.HUGO_PUBLISHDIR instead of hard-coded …
Browse files Browse the repository at this point in the history
…public folder

Fixes #105
  • Loading branch information
razonyang committed Nov 1, 2023
1 parent d26b28a commit ab8dcfe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion purgecss.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const stats = './hugo_stats.json'
const path = require('path')
const fs = require('fs')
fs.access(stats, fs.F_OK, (err) => {
if (err) {
Expand All @@ -8,7 +9,7 @@ fs.access(stats, fs.F_OK, (err) => {

let config = {};
try {
let rawConfig = fs.readFileSync('./public/.build/purgecss.json')
let rawConfig = fs.readFileSync(path.join(process.env.HUGO_PUBLISHDIR, '.build/purgecss.json'))
config = JSON.parse(rawConfig)
} catch (err) {
throw new Error(`Failed to parse runtime PurgeCSS config.\nPlease enable the "--renderToDisk" if you are using Hugo server.\n${err}`)
Expand Down

0 comments on commit ab8dcfe

Please sign in to comment.