Guys, the task is to exclude the class .is-active (it is generated by js-code, but styles are set in the .scss file) when checking gulp-uncss. Currently this class is being deleted ...

gulp.task("sass", function () { return gulp.src("Full/scss/destinationStyles.scss") .pipe(sourcemaps.init()) .pipe(sass()) .pipe(autoprefixer({browsers: ['last 2 versions', '>5%', 'IE 7', 'IE 8', 'IE 9']})) .pipe(cleanCss({compatibility: "ie8"})) .pipe(combineMq({ beautify: false })) .pipe(uncss({ html: ["Full/index.html"], ignore: [".is-active"] })) .pipe(sourcemaps.write("./")) .pipe(gulp.dest("Full/css")) .pipe(notify("Good job!")) .pipe(browserSync.reload ({ stream: true })) }); 

How to solve this problem?

    2 answers 2

    In the styles, specify a comment before the line that falls under the exception. Below is an example of CSS. Saas will need a comment that is not deleted upon compilation.

     /* uncss:ignore */ .selector1 { /* this rule will be ignored */ } 

      There is such a solution to this problem, so the .is-active class looks in all files and is ignored.

       .pipe(uncss({ html: ["Full/index.html"], ignore: [/\.is-active/] }))