Remove Unused CSS From Laravel Project
In this post we will use spatie/laravel-mix-purgecss to remove unused CSS from Laravel Project
Step 1: Install the package
In order to use this package you must be using laravel-mix
version 5.0.0 or higher. We'll install the package using npm
npm install laravel-mix-purgecss --save-dev
Step 2: How to use
require the package inside your webpack.mix.js file and then add it at the end of mix chain.
const mix = require('laravel-mix'); require('laravel-mix-purgecss'); mix.js('resources/js/app.js', 'public/js') .sass('resources/sass/app.scss', 'public/css') .purgeCss();
Now when you will build production assets all of the unused CSS will be removed.
For advance usage please visit the GitHub page of the package.
Shivendra Kumar