Uncss all pages in a site?

479 Views Asked by At

Using gulp, can uncss scrape through all linked pages in a domain without having to specify each page?

Currently uncss is setup like so:

var gulp = require('gulp');
var uncss = require('gulp-uncss');

gulp.task('default', function () {
    return gulp.src('site.css')
        .pipe(uncss({
            html: ['localhost/', 'localhost/page1/', ... 'localhost/pageX/'],
            ignore: [classes not to remove if not found]
        }))
        .pipe(gulp.dest('./out'));
});
1

There are 1 best solutions below

0
On

Try using the wildcard asterik like this.

var gulp = require('gulp');
var uncss = require('gulp-uncss');

gulp.task('default', function () {
return gulp.src('site.css')
    .pipe(uncss({
        html: ['localhost/*.html/', 'localhost/**/*.html'],
        ignore: [classes not to remove if not found]
    }))
    .pipe(gulp.dest('./out'));
});

This * will pick up any file with an html ending in that particular folder and the ** will let it dive deeper into the folder structure.