Postcss: Plugin request: Remove unused styles from CSS

Created on 11 Mar 2016  ·  3Comments  ·  Source: postcss/postcss

It'll be very helpful if in PostCSS there will be some plugin to remove unused styles like in UnCSS. Can we do something like this using PostCSS and maybe something like PostHTML?

Because using UnCSS after PostCSS works very slow and Gulpfile.js looks dirty:

var gulp = require('gulp');
var nano = require('gulp-cssnano');
var postcss = require('gulp-postcss');
var uncss = require('gulp-uncss');

gulp.task('postcss', function () {
  var processors = [
    // list of many plugins
  ];
  return gulp.src('src/css/*.css')
    .pipe(postcss(processors))
    .pipe(uncss({
        html: ['dist/index.html']
    }))
    .pipe(nano())
    .pipe(gulp.dest('dist/css/'))
    .pipe(browserSync.stream());
});

Most helpful comment

All 3 comments

/cc @ben-eb

@ben-eb Awesome!

Was this page helpful?
0 / 5 - 0 ratings