5

I want to use PurifyCSS in Laravel but I can't get it to work.

Stack

Laravel: 5.5.4

NPM: 6.0.0

Node.js: 8.10

Code

mix.styles([
    'resources/assets/css/panel/a.css',
    'resources/assets/css/panel/b.css',
    'resources/assets/css/panel/c.css',
    'resources/assets/css/panel/d.css',
], 'public/css/panel.css').options({
    purifyCss: {
        purifyOptions: {
            info: true,
            rejected: true,
            minify: true
        },
        paths: ['resources/views/admin-layout.blade.php'],
        verbose: true
    },
});

I searched on the internet but couldn't find anything. I want to strip unused CSS from all Blade pages. Even on this link, nobody answered with the correct answer. Even if PurifyCSS is first, it's not working.

Thanks for the help.

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
MohNj
  • 506
  • 1
  • 6
  • 18

1 Answers1

3

Relatively simple as you can declare the mix variable and then set your options.

const mix = require('laravel-mix');

mix.options({
    purifyCss: true
});

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');
Karl Hill
  • 12,937
  • 5
  • 58
  • 95
  • PurifyCSS support is no longer available. We recommend using PurgeCss + postCss instead. @KarlHill – kodfire Oct 20 '21 at 08:00