Sergio Xalambrí

Purge unused CSS with TailwindCSS

TailwindCSS now comes with built-in support to purge the unused CSS, to use this creeate, if you don't already have, a tailwind.config.js file in your project root, inside it export an object, using CommonJS syntax, and there define a property purge with an array of the globs to use to find which files are using Tailwind.

module.exports = {
  purge: [

In our example we are searching for any .ts or .tsx file inside any level of folders inside the src folder in the root.

We could also disable it by passing false instead of an array.

module.exports = {
  purge: false

This is helpful if we are purging them using another tool.