I’m having some confounding trouble getting PurgeCSS working. I’ve followed all the instructions to a T, even some that were not part of the instructions but were necessary for it to supposedly work. Researched all the help I could find on this forum and the general web. And no matter what I get the same issue.
When I run hugo serve I get the following error:
$ hugo server  --verbose
Start building sites …
hugo v0.103.0-beebf2afb09a7be36cf12bdec8a99ae9286504e2+extended windows/amd64 BuildDate=2022-09-15T16:23:56Z VendorInfo=gohugoio    
INFO 2022/09/25 12:24:57 syncing static files to \
INFO 2022/09/25 12:24:57 postcss: The filename, directory name, or volume label syntax is incorrect.                                syntax is incorrect.
Error: Error building site: POSTCSS: failed to transform "css/custom.css" (text/css): The filename, directory name, or volume label 
syntax is incorrect.
Git test repo is here:
Let me spell out my environment:
- Project root is 
C:\_plain\(It was in another location and I wondered if the spaces in the path name were causing issues but it seems not, at least the error hasn’t changed) - I have 
node v18.9.1&npm 8.19.2installed which are the very latest - In my project root, I ran the following commands:
 
$ npm init -y
$ npm install postcss postcss-cli @fullhuman/postcss-purgecss
$ npm list
_plain@1.0.0 C:\_plain
├── @fullhuman/postcss-purgecss@5.0.0
├── postcss-cli@10.0.0
└── postcss@8.4.16
- 
I’ve even tried it with also installing
autoprefixerbut that didn’t do anything (I don’t know what it does but I saw a lot of people include it but it’s not part of the official guide) - 
I have the following
postcss.config.jsas directed by the official guide for Hugo 
const purgecss = require("@fullhuman/postcss-purgecss")({
  content: [".\hugo_stats.json"],
  defaultExtractor: (content) => {
    const els = JSON.parse(content).htmlElements;
    return [...(els.tags || []), ...(els.classes || []), ...(els.ids || [])];
  },
  safelist: [],
});
module.exports = {
  plugins: [
    ...(process.env.HUGO_ENVIRONMENT === "production" ? [purgecss] : []),
  ],
};
- My 
head.htmlpartial contains the following: 
<head>
  {{ $css := resources.Get "css/custom.css" | resources.PostCSS }}
  {{ if hugo.IsProduction }}
    {{ $css = $css | minify | fingerprint "sha256" | resources.PostProcess }}
  {{ end }}
  <link
  rel="stylesheet"
  href="{{ $css.RelPermalink }}"
  crossorigin="anonymous"
  integrity="{{ $css.Data.Integrity }}"
  media="all" />
</head>
- My 
config.tomlcontains the following: 
baseURL = 'http://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
[build]
  writeStats = true
No matter what I do, I get the same error. And there is no insight online as to what could be wrong.
I’m at a loss and the main website I’m working on, which is a private repo, uses bootstrap scss and the final size is ~300kb, most of it unused, so I really want PurgeCSS to work.