DrewRoberts's avatar

Laravel Mix not running PostCSS plug-ins

Could someone let me know what I am doing wrong in my webpack.mix.js file?

I installed the PostCSS plug-ins through NPM but they are not running:

mix.sass('resources/sass/website.scss', 'public/css', {},
        [ purgecss({ 
            enabled: true, 
            content: [
                'resources/views/website/**/*.php',
                'resources/views/website/*.php',
            ],
            variables: true,
        }),
    ])
    .options({
        postCss: [
            require('cssnano')({
                discardComments: {
                    removeAll: true,
                },
            }),
            require('postcss-no-important')(),
        ]
});
0 likes
3 replies
bobbybouwmann's avatar

You need to call purgeCss after your sass, and specify the options for postCss.

For example

mix.sass('resources/sass/app.scss', 'public/css')
    .options({
        processCssUrls: false,
        postCss: [ tailwindcss('./tailwind.config.js') ]
    })
    .purgeCss({
        enabled: mix.inProduction(),
        folders: ['src', 'templates'],
        extensions: ['html', 'js', 'php', 'vue'],
    });

Please or to participate in this conversation.