How do I run PurgeCSS on local URLs?

31 views Asked by At

I'm trying to switch from UnCSS to PurgeCSS because UnCSS seems abandoned.

I set some local URLs in my purgecss gulpfile like this:

const purgecss_options = {
  content: [
    'https://example.ddev.site/top',
    'https://example.ddev.site/style-guide',

However, when I run gulp, the resulting CSS file is empty. PurgeCSS reports no errors, but it doesn't seem to be accessing the specified webpages.

I then tried saving the page locally and using the file in the config:

const purgecss_options = {
  content: [
    'index.html',

This properly purges the CSS and I get a CSS file about 20 kB in size.

But, if possible, I want to run PurgeCSS against my local dev server (which is what I did with UnCSS). The reason is that the files on the server change from time to time, and it's a pain to regenerate all the pages I need to purge CSS from each time (there are about 30 in total).

Is there some way to run PurgeCSS against URLs?

1

There are 1 answers

0
Patrick Kenny On

Specifying URLs is not supported. So you have to do something like use gulp to automate the downloads instead, which I did using gulp-download2.