Clean up unused CSS with PurgeCSS on Laravel and WordPress

I read recently the article How I dropped 250KB of dead CSS weight with PurgeCSS and thought I should put out my setup for this situation. I use Laravel Mix for both Laravel development and also for my WordPress work. My main stack includes Vue.js and TailwindCSS, so these snippets will do just fine when working with these frameworks. Beyond that I can’t make any promises.

But as an endorsement to PurgeCSS, I will tell you, that for the past few projects I have done in WordPress, I managed to get my CSS file down to around 50 kB minified.

My Laravel config file looks like this

let mix = require('laravel-mix');
host: 'localhost',
port: 3000,
proxy: ''
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/css/main.scss', 'public/css')
processCssUrls: false,
if (mix.inProduction()) {


My WordPress config file looks like this

let mix = require("laravel-mix");
let tailwindcss = require("tailwindcss");
const purgecssWordpress = {
whitelistPatterns: [
proxy: "custom.local",
files: ["./**/*.css", "./**/*.js", "./**/*.php", "./*.php"]
.js("assets/js/custom/custom.js", "assets/js")
.postCss("assets/css/style.css", "./", [
publicPath: "./"
// enabled: true,
globs: [
path.join(__dirname, './../**/*.css'),
path.join(__dirname, './../**/*.php'),
path.join(__dirname, './../**/*.vue'),
path.join(__dirname, './../src/**/*.js'),
extensions: ['html', 'js', 'php', 'vue', 'css'],
whitelistPatterns: purgecssWordpress.whitelistPatterns