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

Minification

The first plugin we are going to look at is the minify plugin (https://www.npmjs.com/package/gulp-minify). This plugin lets you minify your JavaScript source. We can install it using npm:

npm install gulp-minify --save-dev

Now we can simply get some source, pipe it to the minify plugin, and output the results:

var gulp = require('gulp');var minify = require('gulp-minify');gulp.task('minify', function () {   gulp.src('scripts/*.js')      .pipe(minify({         ext:{            src:'.debug.js',            min:'.js'         }      }))      .pipe(gulp.dest('prod'));});gulp.task('default', ['minify']);

Now, when you run Gulp, you will see a prod folder containing all the scripts twice, a .debug.js and a .js variant. The ext object lets you specify the input and output suffixes. It is ...

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