-
-
Notifications
You must be signed in to change notification settings - Fork 244
Open
Labels
Description
Describe the bug
When using the cli and specifing the --config flag the file is incorrectly imported using await import, which creates an object with this structure:
{
default: {}, // config
'module.exports': {} // same config again
}This is later merged with the other options, but the options never take effect.
This happens if you use the module.exports = {} syntax, which is explained in the docs.
This will work if you use an es module syntax, like so:
export const content = [];
export function defaultExtractor(content) { }
export const safelist = { };But you will then get a warning from Node.js:
(node:2234469) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///.../purgecss.config.js is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.To Reproduce
- Create a config file as per docs.
- Create any css file named
site.css. - Edit
node_modules/purgecss/bin/purgecss.jsto log the output of the config:options.skippedContentGlobs = skippedContentGlobs; if (output) options.output = output; + console.log('***', options); return options; - Run:
purgecss --config ./purgecss.config.js --css site.css --rejected
Expected Behavior
Configuration from cli args are merged into config from file and config file is not ignored.
Environment
Ubuntu 24, Node 23.10.0, Npm 10.9.2
@fullhuman/[email protected]
[email protected]
Add any other context about the problem here
This does not seem to be a docs only issue, as a warning is emitted by Node.js.
Code of Conduct
- I agree to follow this project's Code of Conduct
giggio, cssandstuff and ofrias