Sebastian De Deyne over at Spatie is working on a Purgecss package for Laravel Mix. The package provides zero-config Purgecss for your average Laravel project:
let mix = require('laravel-mix');
require('laravel-mix-purgecss')();
// ...
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.purgeCss();
All HTML, JS, PHP, and Vue files in the app and resource folders get scanned for selectors, and Purgecss is only enabled in production.
Most project shouldn’t need it, but if you need to go beyond the basics, you can configure Purgecss options and three options provided by the laravel-mix-purgecss
package:
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.purgeCss({ /* My options */ });
Check the readme for more information on how to configure Purgecss and the additional custom options this package provides Laravel Mix.
If you are not familiar with Purgecss:
Purgecss is a tool to remove unused CSS. It can be used as part of your development workflow. Purgecss comes with a JavaScript API, a CLI, and plugins for popular build tools.
This package gives you Purgecss for free on your Laravel projects, so you can install it and benefit from smaller CSS files in production. Boom!
0 comments:
Post a Comment
Thanks