Socket
Socket
Sign inDemoInstall

gulp

Package Overview
Dependencies
98
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gulp

The streaming build system


Version published
Maintainers
1
Install size
4.43 MB
Created

Package description

What is gulp?

Gulp is a toolkit that helps developers automate and enhance workflows. It is a streaming build system that allows the use of Node streams to read files from the filesystem, transform them, and output them back to the filesystem or elsewhere. Gulp is commonly used for tasks such as minification, concatenation, cache busting, unit testing, linting, and optimization.

What are gulp's main functionalities?

Task Automation

Automate repetitive tasks with custom defined tasks.

const gulp = require('gulp');
gulp.task('default', function() {
  // Your task code here
});

File Minification

Minify JavaScript files to reduce their size for production.

const gulp = require('gulp');
const uglify = require('gulp-uglify');
gulp.task('minify-js', function() {
  return gulp.src('src/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('dist'));
});

File Concatenation

Concatenate multiple files into a single file.

const gulp = require('gulp');
const concat = require('gulp-concat');
gulp.task('concat-js', function() {
  return gulp.src('src/*.js')
    .pipe(concat('all.js'))
    .pipe(gulp.dest('dist'));
});

Sass Compilation

Compile Sass files into CSS.

const gulp = require('gulp');
const sass = require('gulp-sass');
gulp.task('sass', function() {
  return gulp.src('src/*.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('dist/css'));
});

Live Reloading

Automatically reload the browser when files are modified.

const gulp = require('gulp');
const browserSync = require('browser-sync').create();
gulp.task('serve', function() {
  browserSync.init({
    server: './dist'
  });
  gulp.watch('src/*.html').on('change', browserSync.reload);
});

Other packages similar to gulp

Changelog

Source

3.8.8

  • update dependencies (minimist, tildify)
  • documentation tweaks

Readme

Source

gulp NPM version Downloads Support us Build Status Coveralls Status

The streaming build system

Like what we do?

Support us via gittip

Documentation

For a Getting started guide, API docs, recipes, making a plugin, etc. see the documentation page!

Sample gulpfile.js

This file is just a quick sample to give you a taste of what gulp does.

var gulp = require('gulp');
var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var sourcemaps = require('gulp-sourcemaps');
var del = require('del');

var paths = {
  scripts: ['client/js/**/*.coffee', '!client/external/**/*.coffee'],
  images: 'client/img/**/*'
};

// Not all tasks need to use streams
// A gulpfile is just another node program and you can use all packages available on npm
gulp.task('clean', function(cb) {
  // You can use multiple globbing patterns as you would with `gulp.src`
  del(['build'], cb);
});

gulp.task('scripts', ['clean'], function() {
  // Minify and copy all JavaScript (except vendor scripts)
  // with sourcemaps all the way down
  return gulp.src(paths.scripts)
    .pipe(sourcemaps.init())
      .pipe(coffee())
      .pipe(uglify())
      .pipe(concat('all.min.js'))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('build/js'));
});

// Copy all static images
gulp.task('images', ['clean'], function() {
  return gulp.src(paths.images)
    // Pass in options to the task
    .pipe(imagemin({optimizationLevel: 5}))
    .pipe(gulp.dest('build/img'));
});

// Rerun the task when a file changes
gulp.task('watch', function() {
  gulp.watch(paths.scripts, ['scripts']);
  gulp.watch(paths.images, ['images']);
});

// The default task (called when you run `gulp` from cli)
gulp.task('default', ['watch', 'scripts', 'images']);

Incremental Builds

We recommend these plugins:

  • gulp-changed - only pass through changed files
  • gulp-cached - in-memory file cache, not for operation on sets of files
  • gulp-remember - pairs nicely with gulp-cached
  • gulp-newer - pass through newer source files only, supports many:1 source:dest

Want to contribute?

Anyone can help make this project better - check out the Contributing guide!

Bitdeli Badge

FAQs

Last updated on 07 Sep 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc