Answer the question
In order to leave comments, you need to log in
Is there a css minification plugin for gulp, with file concatenation?
Hello, I'm switching from grunt to gulp, I ran into some issues:
1) You could pass an array with styles to grunt css-min, and it minified and at the same time concatenated everything into one styles.min.css file. For gulp, I do this:
// styles
gulp.task('styles', function() {
return gulp.src(paths.styles)
.pipe(sass({ compass: true, style: 'expanded', sourcemap: true } ))
.pipe(prefix('last 3 version', 'ie 8', 'ie 9', 'Opera 12.1'))
.pipe(gulp.dest('css/'))
.pipe(rename({ suffix: '.min' }))
.pipe(compressor())
.pipe(gulp.dest('css/'));
});
It turns out that all operations are done with compiled scss files, is it possible to somehow add other styles to this task, for example from bower_components? Or do you need a separate task? Well, another problem, in order to add the .min suffix, I had to install the rename plugin, but it also duplicates the map file with the same suffix, but this is not necessary. Is there an easier way to solve this problem?
2) When adding return to the task callback, the execution time is much longer than without it, but it looks more like the truth, I have seen examples with and without it, what does this mean?
Answer the question
In order to leave comments, you need to log in
gulp.task('sass', function () {
return gulp.src(paths.styles)
.pipe(sass({ compass: true, style: 'expanded', sourcemap: true }))
.pipe(prefix('last 3 version', 'ie 8', 'ie 9', 'Opera 12.1'))
.pipe(gulp.dest('css/'));
});
gulp.task('css', ['sass'], function () {
return gulp.src(["/css", "!/css/*.min.css", "!/css/styles.css", "/external/**/*.css"])
.pipe(concat('styles.css'))
.pipe(gulp.dest('css/'))
.pipe(rename({ suffix: 'min'}))
.pipe(minCSS())
.pipe(gulp.dest('css/'));
});
gulp.task('default', ['css'], function () {
gulp.watch(paths.styles, ['css']);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question