spatie / laravel-mix-purgecss

Zero-config Purgecss for Laravel Mix
https://spatie.be/en/opensource
MIT License
874 stars 38 forks source link

Jigsaw Purge Css No Content provided #51

Closed espositodaniele closed 6 years ago

espositodaniele commented 6 years ago

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:

:point_right: Erorr: No content provided

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

Thanks

espositodaniele commented 6 years ago

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 :laughing:

jonasbrenig commented 5 years ago

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'],
    });