purgecss
purgecss copied to clipboard
[Bug]: Upgrading from 5 to 6: illegal operation on a directory
Describe the bug
I upgraded from purgecss 5 to 6, but I have started to get these errors. Not sure where they come from. Seems to be related to glob.
node:internal/process/promises:391
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: EISDIR: illegal operation on a directory, read] {
errno: -21,
code: 'EISDIR',
syscall: 'read'
}
Node.js v22.6.0
To Reproduce
The purgecss.config.ts
import type { UserDefinedOptions } from "purgecss"
export const purgeCSSConfig: UserDefinedOptions = {
content: [".solid/**/*.{js,html,json,svg}", "dist/**/*.{js,html,json,svg}", "**/!(bundle-visualizer.html)"],
css: ["dist/**/*.css", ".solid/**/*.css"],
// this extractor works with Tailwind's class names (e.g. `bg-red-500`, `dark:bg-red-500`, `px-2.5`, `.max-w-[800px]`, `bg-[#FFFFFF]`)
defaultExtractor: (content) => content.match(/[\w#%./:[\]-]+(?<!:)/g) ?? [],
}
The script
import { PurgeCSS } from "purgecss"
import { purgeCSSConfig } from "./purgecss.config.js"
import { writeFileWithStats } from "./lib.js"
async function main() {
if (process.env.NODE_ENV !== "production") {
return
}
const purgeCssResult = await new PurgeCSS().purge(purgeCSSConfig)
await Promise.all([
...purgeCssResult.map(async ({ css, file }) => {
if (file === undefined) {
return
}
await writeFileWithStats(file, file, css)
}),
])
}
await main()
Environment
Node 22, Linux
Add any other context about the problem here
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct