I’m very new to gulp and seeing as how complex the Roots gulpfile is, I’m so lost as to which block of code I should put in my code in.
The usage examples for both packages is as follows:
- CSS Shrink
var gulp = require('gulp'); var cssshrink = require('gulp-cssshrink'); gulp.task('default', function() { gulp.src('css/**/*.css') .pipe(cssshrink()) .pipe(gulp.dest('dist/css/')); });
- Combine Media Queries
var cmq = require('gulp-combine-media-queries'); gulp.task('cmq', function () { gulp.src('src/**/*.css') .pipe(cmq({ log: true })) .pipe(gulp.dest('dist')); });
I tried to put it in the Styles task, but nothing happens:
gulp.task('styles', ['wiredep'], function() { var merged = merge(); manifest.forEachDependency('css', function(dep) { var cssTasksInstance = cssTasks(dep.name); if (!enabled.failStyleTask) { cssTasksInstance.on('error', function(err) { console.error(err.message); this.emit('end'); }); } merged.add(gulp.src(dep.globs, {base: 'styles'}) .pipe(cssTasksInstance)); }); gulp.src(path.dist + 'styles/main.css') .pipe(cssshrink()) .pipe(cmq()) .pipe(gulp.dest(path.dist + 'styles/main.css')); return merged .pipe(writeToManifest('styles')); });
Ideally, I would need to capture the main.css code and implement the cmq
and cssshrink
to it just before it is finally exported into the distribution folder.