laravel-mix-purgecss: Purgecss not working in my Laravel App

I am working on a project where I am using separate assets for frontend and backend.

I am trying to use purge css for frontend with specific folders and views. I don’t think it’s working. Can someone look into my configuration and tell me what to do?

image

mix.scripts([
    'public/website/js/jquery-3.4.1.min.js',
    'public/website/js/popper.min.js',
    'public/website/js/bootstrap.min.js',
    'public/website/js/slick.min.js',
    'public/website/js/modernizr-webp.js',
    'public/website/js/main.js',
    'public/website/js/jssocials.min.js',
], 'public/website/js/script.js');

mix.styles([
    'public/website/css/fontawesome.min.css',
    'public/website/css/bootstrap.min.css',
    'public/website/css/slick.css',
    'public/website/css/slick-theme.css',
    'public/website/css/jssocials.css',
    'public/website/css/jssocials-theme-flat.css',
    'public/website/css/style.css',
], 'public/website/css/main.css').purgeCss({
    enabled: true,
    paths: () => glob.sync([
        path.join(__dirname, 'resources/views/website/**/*.blade.php'),
        path.join(__dirname, 'resources/views/website/*.blade.php'),
        path.join(__dirname, 'resources/views/includes/website.blade.php'),
        path.join(__dirname, 'resources/views/auth/**/*.blade.php'),
        path.join(__dirname, 'resources/views/auth/*.blade.php'),
        path.join(__dirname, 'public/website/js/script.js'),
    ]),
});

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Reverting back to 4.1.0 did the trick. Latest one didi not work on fresh laravel install with tailwind

@avvertix The newest version actually does work. You just have to add the enabled: true option.

^5.0.0-rc.1 isn’t stable yet. I’m kind of surprised Yarn/npm is pulling that in by default. Sorry about that! Gonna try to push out the 5.0 release soon.

Until then, please keep using 4.1.0.

I’m using enabled: mix.inProduction(), so I also downgraded to 4.1 — this worked for me

    "laravel-mix": "^5.0.4",
    "laravel-mix-purgecss": "^4.1",

@mathieuh I didn’t, I gave up as this isn’t a priority item for us now. Whenever I’ll have a lot of time I will look into this again 😉

I experienced the same issue on the version 5.0.0-RC1, going back to version 4.1.0 solved the problem.