This sample shows how you can minify a JavaScript file, print its size in bytes to the terminal, and write the results to the disk.
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var size = require('gulp-size');
var header = require('gulp-header');
var pkg = require('./package.json');
var info = '// <%= pkg.name %>@v<%= pkg.version %>, <%= pkg.license %>\n';
gulp.task('build', function () {
return gulp
.src('./sample.js')
.pipe(uglify())
.pipe(header(info, { pkg : pkg }))
.pipe(size())
.pipe(gulp.dest('./build'));
});You can execute the sample by entering the following command in your terminal.
gulp build