O'Reilly logo

Continuous Integration, Delivery, and Deployment by Sander Rossel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Minifying CSS

Next, we are going to give our CSS the same kind of treatment. I think you pretty much get the point by now, so I will be short about this. First, install the gulp-clean-css package (https://github.com/scniro/gulp-clean-css):

npm install gulp-clean-css --save-dev

The Gulp clean CSS plugin makes use of clean CSS, so for any options, check their documentation, https://github.com/jakubpawlowicz/clean-css. There are a lot of options. I will not go over them, but I am sure you can figure them out if you need them.

And then simply create a task that does the work:

gulp.task('minify-css', function() {   return gulp.src('css/*.css')      .pipe(cleancss({         compatibility: 'ie9'      }))      .pipe(gulp.dest('prod/css'));});

Run the gulp minify-css command ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required