PHPackages                             deshithemes/css-cleaner - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. deshithemes/css-cleaner

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

deshithemes/css-cleaner
=======================

🚀 Laravel CSS Optimizer: Purge unused CSS, Minify styles, Boost website speed &amp; SEO. Zero-config setup for Tailwind, Bootstrap. 30%+ smaller CSS files guaranteed.

v1.1.0(10mo ago)19MITPHPPHP ^8.1

Since Jun 29Pushed 10mo agoCompare

[ Source](https://github.com/DeshiThemes/css-cleaner)[ Packagist](https://packagist.org/packages/deshithemes/css-cleaner)[ RSS](/packages/deshithemes-css-cleaner/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

css-cleaner
===========

[](#css-cleaner)

💥 Laravel package to automatically purge and minify CSS files in the public directory. Clean, optimized, and beginner-friendly with powerful Artisan commands. Made by Ruman 💪

🎨 Laravel CSS Cleaner
=====================

[](#-laravel-css-cleaner)

 **Remove Unused CSS • Minify • Optimize — All in One for Laravel**
 *Created with 💙 by **Ruman***

 [![](https://camo.githubusercontent.com/6e446b0ee96eb5e62200e57c5863cd05ea5590ef39472f0a4bf328440ebd55f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312b2d7265643f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/6e446b0ee96eb5e62200e57c5863cd05ea5590ef39472f0a4bf328440ebd55f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312b2d7265643f7374796c653d666c61742d737175617265) [![](https://camo.githubusercontent.com/52b6f4defac5fdf724bf9f30a11c08bc47c927d345e0a66909b19251cca4e290/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50757267654353532d4175746f6d617465642d677265656e3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/52b6f4defac5fdf724bf9f30a11c08bc47c927d345e0a66909b19251cca4e290/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50757267654353532d4175746f6d617465642d677265656e3f7374796c653d666c61742d737175617265) [![](https://camo.githubusercontent.com/459e84407f602c940d19accc46ed720eb2255f35b2c35639743a1e84a9a22359/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d696e69666965642d4353532d626c75653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/459e84407f602c940d19accc46ed720eb2255f35b2c35639743a1e84a9a22359/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d696e69666965642d4353532d626c75653f7374796c653d666c61742d737175617265) [![](https://camo.githubusercontent.com/f3cd9467f1a2673efb050d325944267a717320385a6e45da3a19f994f9004339/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f773f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/f3cd9467f1a2673efb050d325944267a717320385a6e45da3a19f994f9004339/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f773f7374796c653d666c61742d737175617265)

---

📦 What is This?
---------------

[](#-what-is-this)

**Laravel CSS Cleaner** is a developer-friendly Laravel package that:

✅ Removes unused CSS
✅ Minifies your styles
✅ Optimizes Laravel’s public CSS automatically
✅ Works with **Tailwind**, **Bootstrap**, or custom styles
✅ Requires zero manual searching for dead styles!

---

🌟 Features
----------

[](#-features)

- 🔍 Auto-scans the entire `/public` directory for `.css` files
- ✂️ Removes unused classes using **PurgeCSS**
- 💨 Minifies and compresses CSS after purging
- 📁 Keeps your structure — creates a `/public/css/optimized/` folder
- 🎛️ Artisan-powered: Clean, Minify, or Optimize with one command
- 🧠 Configurable safelist to preserve dynamic classes like `modal`, `fade`, `active`, etc.

---

FeatureIconDescription**Auto Purge**🧹Removes unused CSS classes**Smart Minification**✨Compresses CSS files**Safelist Protection**🛡️Preserves dynamic classes**Zero Config**🎯Works out-of-the-box**Progress Tracking**📊Real-time optimization stats---

⚙️ Installation
---------------

[](#️-installation)

1. Install the package:

```
composer require DeshiThemes/css-cleaner
```

Publish the config file:

```
php artisan vendor:publish --tag=css-cleaner-config
```

or, if not working or not genarating file under `config/csscleaner.php` then run command (optional)

```
php artisan vendor:publish --tag=css-cleaner-config --force
```

Install the required Node.js dependency:

```
npm install @fullhuman/postcss-purgecss --save-dev
```

⚙️ Configuration The configuration file will be published to: `config/csscleaner.php`

```
return [
    /**
     * 🔍 CSS Source Directory
     *
     * Tip: For better performance, specify exact subdirectory when possible:
     * 'css_path' => public_path('css'),
     */
    'css_path' => public_path(),

    /**
     * 📂 Output Directory
     *
     * Important: Directory will be created automatically
     * but parent directory must exist!
     */
    'output_path' => public_path('css/optimized'),

    /**
     * 🔎 Content Files to Scan
     *
     * Pro Tip: Add all file types that might contain CSS class names:
     * - Blade templates
     * - JavaScript components
     * - Markdown files (if using)
     */
    'content_paths' => [
        'resources/views/**/*.blade.php',
        'resources/js/**/*.vue',
        // 'storage/framework/views/*.php' // Uncomment for cached views
    ],

    /**
     * 🛡️ Safelist Configuration
     *
     * Formats:
     * - Exact: 'active'
     * - Wildcard: 'modal-*'
     * - Regex: '/^tooltip/'
     *
     * Always include:
     * - JS-toggled classes
     * - Animation classes
     * - Dynamically generated classes
     */
    'safelist' => [
        // Core classes
        'active', 'show', 'collapse',

        // Bootstrap specific
        'modal', 'fade', 'collapsing',
        '/^carousel/', '/^tooltip/', '/^bs-tooltip/',

        // Add your project-specific classes here
    ],

    /**
     * ⚙️ PurgeCSS Options
     *
     * Recommendation: Keep keyframes and fontFace
     * unless you're manually handling them
     */
    'purge_options' => [
        'keyframes' => true,    // Keep @keyframes
        'fontFace' => true,     // Keep @font-face
        'variables' => false,    // Remove unused CSS variables
        'rejected' => false      // Don't log removed selectors
    ],

    /**
     * ✂️ Minification Options
     *
     * Warning: preserve_license=false will remove all comments
     * including legal/license blocks!
     */
    'minify_options' => [
        'remove_comments' => true,    // Remove all comments
        'preserve_license' => false,  // Remove even license comments
        'advanced' => true            // Enable advanced optimizations
    ]
];
```

You can customize which classes to always keep and where output should go.

🧩 Artisan Commands
------------------

[](#-artisan-commands)

🧩 Command 💡 Description ✅ Usage Example

🧼 css:purge Purges unused CSS from all files in /public php artisan css:purge ✂️ css:minify Minifies the cleaned CSS files php artisan css:minify 🚀 css:optimize Runs both purge + minify together php artisan css:optimize

🧪 Beginner-Friendly Usage 🧼 Purge Only

```
php artisan css:purge
```

🧹 This removes unused CSS classes from `.css` files and puts them in:

`/public/css/cleaned/`✂️ Minify Only

```
php artisan css:minify
```

🎯 After purging, use this to compress styles — whitespace and comments are removed.

🚀 Optimize (Purge + Minify)

```
php artisan css:optimize
```

🔥 Best option for production — a full clean-up + compression in one step.

📁 Example: Input vs Output Input Files:

```
public/css/style.css
public/assets/vendor/bootstrap.css
```

After css:optimize, Output:

```
public/css/cleaned/css/style.css
public/css/cleaned/assets/vendor/bootstrap.css
```

✅ Folder structure is preserved ✅ Only used classes remain ✅ Files are compressed

🔥 Command Reference
-------------------

[](#-command-reference)

### 🛠️ Project Commands

[](#️-project-commands)

CommandIconDescriptionExample`php artisan css:purge`🧹Remove unused CSS`php artisan css:purge --safelist="active,modal-*"``php artisan css:minify`✨Minify CSS files`php artisan css:minify --path=public/css``php artisan css:optimize`🚀Purge + Minify together`php artisan css:optimize --stats`### 🌍 Global Commands

[](#-global-commands)

CommandIconDescriptionExample`css-cleaner purge`🌐🧹Global purge`css-cleaner purge --path=/var/www/project``css-cleaner minify`🌐✨Global minify`css-cleaner minify --output=dist``css-cleaner optimize`🌐🚀Global optimization`css-cleaner optimize --verbose`🎨 Command Colors &amp; Styles
-----------------------------

[](#-command-colors--styles)

### Regular command (white)

[](#regular-command-white)

```
php artisan css:purge
```

### Optional flags (cyan)

[](#optional-flags-cyan)

```
php artisan css:optimize --stats
```

### Path arguments (yellow)

[](#path-arguments-yellow)

```
php artisan css:minify --path=public/css
```

### Safelist values (green)

[](#safelist-values-green)

```
php artisan css:purge --safelist="active,show"
```

### 🛠️ Advanced Usage

[](#️-advanced-usage)

1. Custom Paths
---------------

[](#1-custom-paths)

```
php artisan css:optimize --css-path=public/assets --output=public/dist
```

2. Safelist Patterns
--------------------

[](#2-safelist-patterns)

```
php artisan css:purge --safelist="active,modal-*,/^tooltip/"
```

3. CI/CD Integration (GitHub Actions)
-------------------------------------

[](#3-cicd-integration-github-actions)

```
- name: Optimize CSS
  run: |
    php artisan css:optimize
    git add public/css/cleaned
    git commit -m "Optimized CSS"
```

4. Dry Run (Test Only)
----------------------

[](#4-dry-run-test-only)

```
php artisan css:purge --dry-run
```

5. Get detailed output with `--verbose:`
----------------------------------------

[](#5-get-detailed-output-with---verbose)

```
css-cleaner optimize --verbose
```

6. Preserve folder structure with:
----------------------------------

[](#6-preserve-folder-structure-with)

```
php artisan css:optimize --keep-structure
```

🚀 When to Use
-------------

[](#-when-to-use)

SituationIconBenefit**Before Production**🚀Boost performance by 50-90%**Bootstrap/Tailwind Sites**🧹Remove 80-95% unused CSS**Portfolio/Business Sites**⚡Faster loading pages**After View Updates**🔄Keep CSS lean**CI/CD Pipelines**🤖Automate optimization💡 Pro Tips
----------

[](#-pro-tips)

### 1. Always safelist JS classes

[](#1-always-safelist-js-classes)

```
--safelist="show,collapse,fade"
```

### 2. Run after every deploy

[](#2-run-after-every-deploy)

```
php artisan css:optimize
```

### 3. Add to deployment scripts

[](#3-add-to-deployment-scripts)

```
# forge.sh or github-actions.yml
```

🔥 Compatibility
---------------

[](#-compatibility)

💡 **Core Requirements:** PHP 8.1+ • Laravel 10+ • Node.js 16+

TechnologyIconVersionHighlight**PHP**🐘`8.1 - 8.4`✓ Fully Supported**Laravel**🎯`10.x - 12.x`✓ Optimized**Bootstrap**🅱️`4.x - 5.x`⚠️ v3 needs config**Tailwind**🌪️`All versions`✓ Perfect match**Laravel Mix**🎨`v6+`✓ Works great**Vite**⚡`v3+`➜ Post-build only**Custom CSS**✨Any `.css`✓ Universal**🔧 Version Details**### Verify your environment matches:

[](#verify-your-environment-matches)

```
php -v        # Requires 8.1+
```

composer show laravel/framework # Requires 10+

```
node -v       # Requires 16+
```

Project TypeBenefit of Using This Package🛍 eCommerce (Bootstrap)Smaller styles, faster checkout UX📚 LMS Site (Tailwind)Less bloat, faster page loads🧑‍🎨 PortfolioLight footprint for static sites🏢 Business WebsiteQuick, optimized performance📊 Admin PanelClean dashboard assets📊 Benchmark Results
-------------------

[](#-benchmark-results)

**Scenario****Original Size****Optimized Size****Reduction**Bootstrap 5187 KB24 KB**87%**Tailwind1.2 MB28 KB**98%**---

🌍 Global Command Setup
----------------------

[](#-global-command-setup)

### 1. Install Globally

[](#1-install-globally)

```
composer global require deshithemes/css-cleaner
```

2. Add to PATH
--------------

[](#2-add-to-path)

```
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
source ~/.bashrc
```

3. Verify Installation
----------------------

[](#3-verify-installation)

```
css-cleaner --version
```

### Global Usage Examples

[](#global-usage-examples)

Optimize any project

```
css-cleaner optimize --path=/var/www/project/public

# Minify specific directory
css-cleaner minify --path=./public/css
```

### 🛠️ Troubleshooting

[](#️-troubleshooting)

Permission Issues
-----------------

[](#permission-issues)

```
sudo chown -R $USER:$USER ~/.composer/
```

Command Not Found
-----------------

[](#command-not-found)

```
composer global bin deshithemes/css-cleaner install
```

Windows Users
-------------

[](#windows-users)

```
# Use full path to composer binaries
php C:\Users\You\AppData\Roaming\Composer\vendor\bin\css-cleaner optimize
```

❓ FAQ
-----

[](#-faq)

 **🔮 Will this break my JavaScript classes?** No! The safelist protects dynamic classes. Test in staging first.  **⏱ How often should I run this?** Before every production deployment or after CSS changes.  **⚡ Does this work with Vite?** Yes! Works with any build system (Vite, Mix, etc.) 💖 Support
---------

[](#-support)

 [ ![](https://camo.githubusercontent.com/8f331d2a19a07c1d38bb3da5dcc87abe30cdee751c52a187c2e70e8e2d44727d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652fe29c89efb88f5f456d61696c2d4431343833363f7374796c653d666f722d7468652d6261646765266c6f676f3d676d61696c266c6f676f436f6c6f723d7768697465) ](mailto:roman.civil2019@gmail.com) [ ![](https://camo.githubusercontent.com/4c1cbf9cc2709476318463bbdd00c4fe1d0982a3c9c5087c4e3708c51b7e8f4e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652ff09f909e5f4973737565732d3138313731373f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465) ](https://github.com/DeshiThemes/css-cleaner/issues) [ ![](https://camo.githubusercontent.com/ef29d985f33d47bc99c125d4c88cf12dfb9a9fa4655a4cc23e0c051d42a4080e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652fe2ad905f537461722d4646443730303f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d626c61636b) ](https://github.com/DeshiThemes/css-cleaner/stargazers)

 **✨ Crafted with ❤️ by [Ruman](https://github.com/DeshiThemes)**

 ```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance54

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

314d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4aac2e7b1e1baafe5b7a8cd3853cbbc9296d5142cf3cb853a51f273574a083f3?d=identicon)[sakib-hasan-ruman](/maintainers/sakib-hasan-ruman)

---

Top Contributors

[![DeshiThemes](https://avatars.githubusercontent.com/u/85276039?v=4)](https://github.com/DeshiThemes "DeshiThemes (6 commits)")

---

Tags

laravelcssperformanceminifytailwindoptimizationbootstrapfrontendoptimizerpurgecss

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/deshithemes-css-cleaner/health.svg)

```
[![Health](https://phpackages.com/badges/deshithemes-css-cleaner/health.svg)](https://phpackages.com/packages/deshithemes-css-cleaner)
```

###  Alternatives

[webpatser/laravel-uuid

Laravel integration for webpatser/uuid - High-performance drop-in UUID replacements (15% faster than Ramsey). Provides Str macros, HasUuids trait, facades, and casts. RFC 4122/9562 compliant.

1.8k17.3M128](/packages/webpatser-laravel-uuid)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k5.4k1](/packages/vinkius-labs-laravel-page-speed)[krisawzm/critical-css

A Laravel package for generating and using inline critical-path CSS.

4714.2k2](/packages/krisawzm-critical-css)[fisharebest/laravel-assets

Asset management for Laravel

208.1k](/packages/fisharebest-laravel-assets)[yocmen/html-minify

Minifies the HTML output of Laravel 5 applications (Originally from https://github.com/fitztrev/laravel-html-minify)

1713.7k](/packages/yocmen-html-minify)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
