Skip to content

How to use PurgeCSS for HTML pages generated using a template engine #31

Closed Answered by webdiscus
vralle asked this question in Q&A
Discussion options

You must be logged in to vote

I think the complexity of implementation is much higher than using postcss-purgecss with the contentFunction() therefore solve your special case on the postcss-purgecss side.

I have created the purgecss-postcss example where each page contains own style file and compiled CSS contains only used on the page classes.

Idea:

  • bind style with html via EntryPoint name
  • each output HTML file has the EntryPoint name (the key of the entry option)
  • each page must have own style file with the filename containing name, e.g. for about.html -> about.scss
  • use the contentFunction to retrieve the name form style filename
  • the contentFunction returns the HTML file based in the name of style
pages/
  home/
   …

Replies: 9 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by vralle
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@webdiscus
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@webdiscus
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants