Search code examples
javascriptregexuncssgulp-uncss

uncss, regex pattern for .no-'string', .is-'string'


I'm having some regex woes.

Using gulp-uncss

I'd like to add some classes to the ignore option.

Any class that starts with .no-

Any class that contains .is-

.no-flexbox {}
.test.is-active {}
.test .is-hidden {}


.pipe(uncss({
    html: ['tmp/public_html/*.html'],
    ignore: ['/(.is-)(\w)*', '(.no-)(\w)*']
}))

This isn't quite right


Solution

  • Your regexes look incomplete. May be you should do like this

    .pipe(uncss({
        html: ['tmp/public_html/*.html'],
        ignore: ['/\.no-\w+/g', '/\.\w+\s?\.is-\w+/g']
    }))