gulp-purgecss
TypeScript icon, indicating that this package has built-in type declarations

7.0.2 • Public • Published

gulp-purgecss

npm license

gulp plugin to removed unused CSS, using purgecss

Regarding Issues

This is just a simple gulp plugin, which means it's nothing more than a thin wrapper around purgecss. If it looks like you are having CSS related issues, please go to the purgecss repo. Only create a new issue if it looks like you're having a problem with the plugin itself.

Install

npm i -D gulp-purgecss
npm install --save-dev gulp-purgecss

Usage

By default, purgecss outputs the source CSS with unused selectors removed:

const gulp = require('gulp')
const purgecss = require('gulp-purgecss')

gulp.task('purgecss', () => {
    return gulp.src('src/**/*.css')
        .pipe(purgecss({
            content: ['src/**/*.html']
        }))
        .pipe(gulp.dest('build/css'))
})

By setting the rejected option, you can 'invert' the output to list only the removed selectors:

const gulp = require('gulp')
const rename = require('gulp-rename')
const purgecss = require('gulp-purgecss')

gulp.task('purgecss-rejected', () => {
    return gulp.src('src/**/*.css')
        .pipe(rename({
            suffix: '.rejected'
        }))
        .pipe(purgecss({
            content: ['src/**/*.html'],
            rejected: true
        }))
        .pipe(gulp.dest('build/css'))
})

Versioning

We use SemVer for versioning.

License

This project is licensed under the MIT License - see the LICENSE file for details

Dependencies (5)

Dev Dependencies (6)

Package Sidebar

Install

npm i gulp-purgecss

Homepage

purgecss.com

Weekly Downloads

8,650

Version

7.0.2

License

MIT

Unpacked Size

15.5 kB

Total Files

6

Last publish

Collaborators

  • jsnanigans
  • ffloriel