javascript - Is it possible to ignore a file with unCSS in Gulp? -
i've been looking through google find way want did not succeed.
here's gulp task
gulp.task('less', function() { return gulp.src('css/*.less') .pipe(less()) .pipe(stripcsscomments({ all: true })) .pipe(concat('main.css')) .pipe(uncss({ html: ['index.html'], ignore: [ '.visited', '.ripple', '.rippleeffect', '.ripple2', '.rippleeffect2', '.rippledrop', '.rippledrop2', '.ripple3', '.rippleeffect3', '.rippledrop3', '.slide' ] })) .pipe(minifycss()) .pipe(gulp.dest('build/css')) });
as can see have lot of classes ignored. getting worse new css frameworks has dozens of classes called javascript (so uncss erase them). instead of putting 30 classes in ignore option, i'd ignore .css contains dynamic classes.
the point is, still want events.css concatened others css, has go in pipe (i want single .css file website).
or should make second .less function, merge uncss files non-uncss files ? i'm not sure whats best way achieve want
the last point 1 go for, don't have 2 functions, can use stream merging:
var merge = require('merge2'); gulp.task('less', function() { var streammain = gulp.src(['css/*.less', '!css/events.less']) .pipe(less()) .pipe(stripcsscomments({ all: true })) .pipe(uncss({ html: ['index.html'] })); var streamevents = gulp.src('css/events.less') .pipe(less()) .pipe(stripcsscomments({ all: true })); return merge(streammain, streamevents) .pipe(concat('main.css')) .pipe(minifycss()) .pipe(gulp.dest('build/css')); });
in gulp, plugins should 1 thing. related handling files in hand :-)
Comments
Post a Comment