spatie/laravel-mix-purgecss

Jigsaw Purge Css No Content provided

espositodaniele opened this issue · 2 comments

Hello there,

I'm trying to use the purgeCss/laravel mix plugin in my webpack configuration to remove unused css from my project with no success.

webpack.mix.js

const { mix } = require('laravel-mix');
let build = require('./tasks/build.js');
var tailwindcss = require('tailwindcss');
require('laravel-mix-purgecss');

mix.disableSuccessNotifications();
mix.setPublicPath('source/assets/build');
mix.webpackConfig({
    plugins: [
        build.jigsaw,
        build.browserSync(),
        build.watch(['source/**/*.md', 'source/**/*.php', 'source/**/*.scss', '!source/**/_tmp/*']),
    ]
});

mix.options({
    postCss: [ tailwindcss('./tailwind.js') ],
    processCssUrls: false,
});

mix.js('source/_assets/js/main.js', 'js')
    .sass('source/_assets/sass/main.scss', 'css')
    .purgeCss();

When i run npm run production i got this error:

👉 Erorr: No content provided

Did anyone face this error?
I will really appreciate any help.

Thanks

When using laravel-mix-purgecss outside of Laravel, you need to tell it where to look.

Didn't read with attention the documentation provided. It happens sometimes 😆

For anybody else wondering, like me:
You have to specify the output-path

mix.sass('src/css/style.scss', 'dist/css/')
    .options({
        processCssUrls: false,
        postCss: [tailwindcss('./tailwind.config.js')],
    })
    .purgeCss({
        folders: ['dist'],
    });