Proper way to integrate Purify CSS and Clean CSS

We are working on an AMP version of a middleman website. It’s already based on Bootstrap, we need to reduce the size of our CSS. As described in more details here https://www.uncompiled.org/blog/2016/amp-bootstrap/ an easy way to achieve the goal is to use PurifyCSS and CleanCSS.

PurifyCSS need to run after the build is complete because it analyses the HTML and JS of the website to find unused CSS.

We use webpack as external pipeline so we can integrate CleanCSS using https://github.com/retyui/clean-css-loader. Also PurifyCSS has an integration with webpack but we need to run it after middleman has build the html but we haven’t found a solution.

1 Like