Skip to content

Option to override default content globs passed to PurgeCSS #1001

Open
@lite-sky

Description

@lite-sky

The content array passed to PurgeCSS().purge() contains default globs:

  • ${outDir}/**/*.html
  • ${outDir}/**/*.js

It would be nice to have the option to override these globs, rather than have them hard-coded.

My usecase for this is a very large (120k pages) site that is mostly (99%) statically generated. The ${outDir}/**/*.html glob causes a "Maximum call stack size exceeded" error when running astro-purgecss.

Of the 120k pages on my site, there are really only 2 types of pages - each page of the same type is exactly the same except for some content, but the CSS used is exactly the same on all pages of the same type. What I would like to do is to override the default globs with a small set of custom globs that would take only 1 of each type of page. That way, all the used CSS would be found in the 2 pages, without having to have all 120k pages be parsed/globbed.

IMO, ideally, there would be something like 2 additional options, overrideContentHtmlGlobs and overrideContentJsGlobs, which if specified, would replace the currently hard-coded html or js glob with the values in the override options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    astro-purgecssIssues related to astro-purgecss package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions