Streaming css through postcss uncss plugin in order to minimize buffer usage?

375 Views Asked by At

Please let me know if this question is too broad. I'll break it down into more discrete pieces.

We are running into the limits of what the PostCSS uncss plugin can handle when processing large html and css files.

Some of the test files being produced by the @superflycss project are almost a million lines of css long, and will get a lot longer as more modules are added. Here's an example.

Anyways uncss, via PostCSS, is loading the entire CSS and html file at the same time and then performing the matches, and we think this is causing the memory exhaustion. Wanted to see if anyone knows of a way to stream either the css or the html record by record, so that we can get the same results:

  • A trimmed css file that only includes the css selectors used
  • Source maps

These are related issue links:

1

There are 1 best solutions below

0
Ole On BEST ANSWER

It turns out that Chrome (With a lot of tabs open) was eating most my laptops memory, and hence the uncss build was having a hard time. When running the build with about 10G of memory free it completes. Complete a test with uncss running against a million lines of css and it completes in 22 minutes. Test documented here