metalsmith-css-unused

    0.3.2 • Public • Published

    metalsmith-css-unused

    npm Version npm Weekly Downloads

    Known Vulnerabilities Test Coverage Maintainability

    GitHub License

    A Metalsmith plugin to remove unused CSS rules.

    Installation

    npm install --save metalsmith-css-unused

    JavaScript Usage

    This plugin writes output back to the original input file(s).

    const Metalsmith = require('metalsmith');
    const cssUnused  = require('metalsmith-css-unused');
    
    Metalsmith(__dirname)
        .use(cssUnused({
            // options here
        }))
        .build((err) => {
            if (err) {
                throw err;
            }
        });

    Options

    html (optional)

    Type: string Default: **/*.html

    A minimatch glob pattern to find HTML files.

    css (optional)

    Type: string Default: **/*.css

    A minimatch glob pattern to find CSS files.

    purgecss (optional)

    Type: object Default: {}

    An object of PurgeCSS options.

    Example

    const Metalsmith = require('metalsmith');
    const cssUnused  = require('metalsmith-css-unused');
    
    Metalsmith(__dirname)
        .use(cssUnused({
            output: 'static/css/styles.css',
            purgecss: {
                safelist: [
                    // Bootstrap 4 JavaScript
                    /\.carousel-item-.+/,
                    /\.modal/,
                    /\.show/
                ]
            }
        }))

    Changelog

    Changelog

    Install

    npm i metalsmith-css-unused

    DownloadsWeekly Downloads

    2

    Version

    0.3.2

    License

    GPL-3.0-or-later

    Unpacked Size

    40.4 kB

    Total Files

    5

    Last publish

    Collaborators

    • emmercm