Back to the knowledge base

Use PurgeCss with Rails (and TailwindCss)

Sjabloon comes with the amazing TailwindCss, which by default comes with thousands of small utility classes.

For each colour and for each breakpoint there is a small class. All these classes can quickly add up! When working on websites or webapps a never ending goal is to keep it as fast as possible at all times. Keep assets small in size is key in this. That’s why Sjabloon comes with PurgeCss packaged and set up by default.

How it works

PurgeCss works simply by checking for a string within some folders (within Sjabloon this is "./app/views/**/*.html.erb", "./app/helpers/**/*rb", "./frontend/controllers/**/*.js"). If the string matches it will keep the Css in place and will remove it otherwise. It’s important to know that it only can detect complete class names, so if you use any conditionals with your classes, be sure to add the class name in its entirety.

Sjabloon is set up to only run PurgeCss in production, so development is quick and a breeze still to use.

A Rails SaaS starter kit to focus on your core product

Get started

30+ developers, companies and freelancers bought Sjabloon in the last 4 weeks