postcss-purgecss-laravel

A simple wrapper around postcss-purgecss with sensible defaults for Laravel apps

Showing:

Popularity

Downloads/wk

7.1K

GitHub Stars

27

Maintenance

Last Commit

10mos ago

Contributors

3

Package

Dependencies

1

Size (min+gzip)

48.2KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

postcss-purgecss wrapper with sensible defaults for Laravel apps

Software License Latest Version on NPM npm

A simple wrapper around postcss-purgecss with sensible defaults for Laravel apps.

// postcss.config.js

module.exports = {
    plugins: [
        require('postcss-purgecss-laravel')({
            safelist: [/hljs/],
            extend: {
                content: [content: [path.join(__dirname, 'vendor/spatie/menu/**/*.php')],]
            },
        });
    ],
};

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package with yarn or npm:

yarn add postcss-purgecss-laravel --dev
npm install postcss-purgecss-laravel --save-dev

Usage

Register the PostCSS plugin.

// postcss.config.js

module.exports = {
    plugins: [
        require('postcss-purgecss-laravel')(/* ... */);
    ]
}

All options passed to the plugin get passed down to PurgeCSS. Refer to the PurgeCSS docs for an overview of the available options.

// postcss.config.js

module.exports = {
    plugins: [
        require('postcss-purgecss-laravel')({
            safelist: [/hljs/],
        }),
    ],
};

Options will override the default options this package provides. If you'd rather extend the options, place them in the extend option.

// postcss.config.js

module.exports = {
    plugins: [
        require('postcss-purgecss-laravel')({
            extend: {
                safelist: [/hljs/],
            },
        }),
    ],
};

In the above example, the /hljs/ pattern will be added to the safelist, instead of overriding the default safelist option.

These are the defaults this package provides:

const defaultConfig = {
    content: [
        "app/**/*.php",
        "resources/**/*.html",
        "resources/**/*.js",
        "resources/**/*.jsx",
        "resources/**/*.ts",
        "resources/**/*.tsx",
        "resources/**/*.php",
        "resources/**/*.vue",
        "resources/**/*.twig",
    ],
    defaultExtractor: (content) => content.match(/[\w-/.:]+(?<!:)/g) || [],
    safelist: [/-active$/, /-enter$/, /-leave-to$/, /show$/],
};

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100