Closed lunelson closed 6 years ago
what is it logging to your terminal?
It logs the entire purged CSS!
That should not happen by default, can I see your NPM script?
The the following line under scripts
in package.json
is calling the purgecss CLI:
"build:purge": "purgecss --c purgecss.config.js",
The purgecss.config.js
file is this:
module.exports = {
content: ['out/**/*.html'],
css: ['out/app.css'],
fontFace: true
};
And when I run the script, after the first build step is done, it outputs this (minus a few thousand lines):
> purgecss --c purgecss.config.js
[ { file: 'out/app.css',
css: '@font-face{font-family:DIN;src:url(/assets/fonts/FFDinPro/1448138/aca1d56d-ac12-
---a few thousand lines removed---
a{margin-left:1rem}' } ]
This is just running purgecss and that is what purgecss returns, Im guessing you would like to save the output to a new file?
anyway it would be easier to use just have a JS file like this:
// purgeScript.js
var Purgecss = require('purgecss')
var fs = require('fs')
var purgecss = new Purgecss({
content: ['out/**/*.html'],
css: ['out/app.css'],
fontFace: true
})
var purgecssResult = purgecss.purge()
fs.writeFile('out/app.purged.css', purgecssResult[0].css, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
and then just run it like this:
node purgeScript.js
š
Aha so I sort of misunderstood how it worked thenāI thought the CLI would just purge the target file(s) and write it/them back to diskāis there a more generic way to just say "here's a folder of .html
files and .css
files, please purge the CSS in accordance with the content of the HTML"?
Just with the CLI that is not really possible at the moment, but its long overdue to improve the CLI to be able to do this. If you'd like to, please create an Issue on the main repo for purgecss so that we don't forget about it. Let me know if you are having any other problems with purgecss š
I'm using the CLI tool via an NPM script, and a configuration file. There's a huge amount of output in the terminal which causes me to lose my place WRT other output. How do I suppress it?