Purgecss: multiple html files

Created on 11 Mar 2020  路  6Comments  路  Source: FullHuman/purgecss

I need purge a css file which have styles for multiple htmls, I have this script in my package.json:

"scripts":{
...
"postbuild": "purgecss --css build/styles/*.css --content build/*.html build/scripts/*.js --output build/styles"
....
}

but this only take the first file styles and the others are removed

Most helpful comment

when I use the flag --content with a wildcard like --content build/*.html purgecss just purge the css for the first html.
example:

index1.html:

<div class="class1"></div>

index2.html:

<div class="class2"></div>

both files have link to one file like this:

.class1{...}
.class2{...}
.class3{...}
.class4{...}

the output only have:

.class1{....}

spected:

.class1{....}
.class2{....}

All 6 comments

I'm not sure I understand the situation correctly. Do you have a quick repo for me to produce the desire result?

I have the same problem. If I do something like this:
purgecss --config purgecss.config.js --css tailwind_styles.css --content options.js frame.js --output ./out/

It will effectively ignore frame.js.

when I use the flag --content with a wildcard like --content build/*.html purgecss just purge the css for the first html.
example:

index1.html:

<div class="class1"></div>

index2.html:

<div class="class2"></div>

both files have link to one file like this:

.class1{...}
.class2{...}
.class3{...}
.class4{...}

the output only have:

.class1{....}

spected:

.class1{....}
.class2{....}

I have the same problem with my repo (https://github.com/raravi/amithraravi2.com).

Running this command: purgecss --css _site/css/main.css --content _site/index.html _site/**/index.html _site/**/**/index.html _site/**/**/**/index.html dist/main.js --output dist/

Results in a purged file which keeps only content from the first 2 -> _site/index.html _site/**/index.html

For now, I've downgraded to 1.4.2, which seems to work as expected!

The documentation was not updated to reflect the changes.
The list of files should be comma separated.

purgecss --css build/styles/*.css --content build/*.html build/scripts/*.js --output build/styles

should be

purgecss --css build/styles/*.css --content build/*.html,build/scripts/*.js --output build/styles

and

purgecss --config purgecss.config.js --css tailwind_styles.css --content options.js frame.js --output ./out/

should be

purgecss --config purgecss.config.js --css tailwind_styles.css --content options.js,frame.js --output ./out/

Thank you! This worked!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TylerBarnes picture TylerBarnes  路  5Comments

chuckyblack picture chuckyblack  路  3Comments

XhmikosR picture XhmikosR  路  9Comments

simplenotezy picture simplenotezy  路  3Comments

TomS- picture TomS-  路  3Comments