DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Sergio Daniel XalambrΓ­
Sergio Daniel XalambrΓ­

Posted on • Originally published at sergiodxa.com

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: [
    "./src/**/*.{ts,tsx}"
  ],
};
Enter fullscreen mode Exit fullscreen mode

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
};
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.