V
V
Vasily Vyaznikov2016-12-12 17:54:47
gulp.js
Vasily Vyaznikov, 2016-12-12 17:54:47

How to configure gulp-uncss for each page?

Using plugin https://www.npmjs.com/package/gulp-uncss
Code example:

gulp.task('uncss-go', function () {
    return gulp.src('dist/css/main.css')
        .pipe(uncss({
            html: ['dist/index.html']
        }))
        .pipe(gulp.dest('dist/css'));
});

If you use for one page everything works fine, but how to make it work for all pages?
For example, I have an index.html page, index.css styles are attached to it, about.css styles are attached to the about.html page , and so on. ( I think the system is clear ). Creating a different task for each page is, of course, not a solution.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitali Semashkevich, 2019-09-07
@ultima

Hi, the plugin description says:
Options: 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.

i.e. you can write like this:

html: ['index.html', 'posts/**/*.html', 'http://example.com']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question