Laravel-mix: Include purifycss-webpack support

Created on 3 Mar 2017  路  2Comments  路  Source: JeffreyWay/laravel-mix

Hi,

Is it posible to include an option to remove unused css?

It is very useful for people who use HTML templates, LESS loads a lot of module, but very few is actually used.

If not, how should I extend Mix???

I appended

const path = require('path');
const glob = require('glob');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PurifyCSSPlugin = require('purifycss-webpack');

module.exports = {
module: {
    rules: [
        {
            test: /\.css$/,
            loader: ExtractTextPlugin.extract({
                fallbackLoader: 'style-loader',
                loader: 'css-loader'
            })
        }
    ]
},
plugins: [
    new ExtractTextPlugin('[name].[contenthash].css'),
    // Make sure this is after ExtractTextPlugin!
    new PurifyCSSPlugin({
        // Give paths to parse for rules. These should be absolute!
        paths: glob.sync(path.join(__dirname, 'app/*.html')),
    })
]
};

as mentioned in plugin docs, but it is not doing the job...

Most helpful comment

I've pushed an initial pass at this to master. We'll tag it this week, likely. Once we do, you can turn it on with:

mix.options({ purifyCss: true });

All 2 comments

I've pushed an initial pass at this to master. We'll tag it this week, likely. Once we do, you can turn it on with:

mix.options({ purifyCss: true });

Is there a way to pull this, or should we just wait for new release?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pixieaka picture pixieaka  路  3Comments

wendt88 picture wendt88  路  3Comments

sdebacker picture sdebacker  路  3Comments

Micaso picture Micaso  路  3Comments

jpmurray picture jpmurray  路  3Comments