Tailwind Safelist Generator screenshot

Tailwind Safelist Generator

Author Avatar Theme by Spatie
Updated: 4 Jan 2023
99 Stars

Tailwind plugin to generate purge-safe.txt files

Overview

If you’re diving into Tailwind CSS and using dynamic data from a CMS, the tailwind-safelist-generator could be a game changer for your workflow. This clever plugin helps you generate a safelist.txt file that maintains the CSS classes you need, ensuring they remain intact even if they aren’t explicitly referenced in your code. Tailwind’s Just-In-Time (JIT) mode is fantastic, but when it comes to dynamic class generation, a little help goes a long way.

The process of keeping your safelist updated can be tedious, especially with the frequent theme changes. With this tool, the burdensome task of manually syncing your safelist with your theme is simplified, allowing you to focus on what you do best—creating outstanding designs.

Features

  • Automatic Safelist Generation: Effortlessly generate a safelist.txt file based on specified patterns, eliminating the hassle of manual entry.
  • Dynamic Class Support: Perfect for handling classes derived from dynamic data, ensuring they remain in your compiled CSS without manual updates.
  • Integration with Tailwind JIT: Seamlessly integrates with Tailwind’s JIT mode, automatically scanning your codebase for classes while respecting your specified patterns.
  • Custom Patterns: Specify any patterns for class generation, leveraging Tailwind’s theme helper to access a variety of possible values.
  • Project Root Output: By default, it generates the safelist.txt file in the root of your project, keeping everything organized.
  • Version Control Ready: Adds ease to your workflow by allowing you to include safelist.txt in your .gitignore, streamlining your version control processes.
  • Robust Testing: Built with reliability in mind, with tests written using Jest to ensure consistent performance.