JSPM

gulp-uncss-sp

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q24006F
  • License MIT

Remove unused CSS selectors. Insanely copied from gulp-uncss package. Using this module for demonstration. This module is not recommended to be used in any kind of dependencies.

Package Exports

  • gulp-uncss-sp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gulp-uncss-sp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gulp-uncss-sp Build Status

Remove unused CSS with UnCSS.

If you have any difficulties with the output of this plugin, please use the UnCSS tracker.

Install via npm:

npm install gulp-uncss-sp --save-dev

Example

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

gulp.task('simple', function() {
    return gulp.src('site.css')
        .pipe(uncss({
            html: ['index.html', 'about.html']
        }))
        .pipe(gulp.dest('./out'));
});

Glob example

UnCSS does not provide native support for globbing patterns. If you would like gulp-uncss to parse a directory recursively, then you can use the glob module like so:

var glob = require('glob');

gulp.task('glob', function() {
    gulp.src('site.css')
        .pipe(uncss({
            html: glob.sync('templates/**/*.html')
        }))
        .pipe(gulp.dest('./out'));
});

URL example

UnCSS can also visit your website for the HTML it uses to analyse the CSS against. Here is an example:

gulp.task('urls', function() {
    gulp.src('site.css')
        .pipe(uncss({
            html: [
                'http://www.example.com'
            ]
        }))
        .pipe(gulp.dest('./out'));
});

Note that you can mix and match URLs and paths to files using the html option.

Options

This plugin takes slightly different options to the UnCSS module, because it is essentially just a streaming wrapper which returns a CSS stream.

html

Type: Array|String Required value.

An array which can contain an array of files relative to your gulpfile.js, and which can also contain URLs. Note that if you are to pass URLs here, then the task will take much longer to complete. If you want to pass some HTML directly into the task instead, you can specify it here as a string.

ignore

Type: Array Default value: undefined

Selectors that should be left untouched by UnCSS as it can't detect user interaction on a page (hover, click, focus, for example). Both literal names and regex patterns are recognized.

timeout

Type: Integer Default value: undefined

Specify how long to wait for the JS to be loaded.